| 1 |
#!/usr/bin/perl -w |
| 2 |
# |
| 3 |
# ecaccess-event-grant: Grant usage of an ECaccess Event |
| 4 |
# |
| 5 |
# [email protected] - 2010-10-15 |
| 6 |
|
| 7 |
use ECMWF::ECaccess; |
| 8 |
use Getopt::Long; |
| 9 |
use Pod::Usage; |
| 10 |
use Term::ReadKey; |
| 11 |
|
| 12 |
my %opt = ( subscribe => 0, notify => 0, version => 0, help => 0, manual => 0, retry => 0, debug => 0 ); |
| 13 |
|
| 14 |
pod2usage( -noperldoc => 1, -exit => 1, verbose => 1 ) if !GetOptions( |
| 15 |
\%opt, |
| 16 |
qw( |
| 17 |
subscribe |
| 18 |
notify |
| 19 |
version |
| 20 |
help|? |
| 21 |
manual |
| 22 |
retry=i |
| 23 |
debug |
| 24 |
) |
| 25 |
); |
| 26 |
|
| 27 |
# Display version if requested |
| 28 |
die ECMWF::ECaccess->VERSION . "\n" if ( $opt{version} ); |
| 29 |
|
| 30 |
my $eventid = $ARGV[0]; |
| 31 |
my $userList = $ARGV[1]; |
| 32 |
|
| 33 |
pod2usage( -noperldoc => 1, -exit => 1, verbose => 1 ) if ( $opt{help} ); |
| 34 |
pod2usage( -noperldoc => 1, -exit => 1, verbose => 2 ) if ( $opt{manual} ); |
| 35 |
pod2usage( -noperldoc => 1, -exit => 1, verbose => 0, -msg => "No event-id specified!\n" ) if not($eventid); |
| 36 |
pod2usage( -noperldoc => 1, -exit => 1, verbose => 0, -msg => "No users-list specified!\n" ) if not($userList); |
| 37 |
|
| 38 |
# Create the ECaccess Controler |
| 39 |
my $ecaccess = ECMWF::ECaccess->new( $opt{retry}, $opt{debug}); |
| 40 |
|
| 41 |
# Get the Token (using the Certificate in $HOME) |
| 42 |
my $token = $ecaccess->getToken(); |
| 43 |
|
| 44 |
# Get the Control Channel |
| 45 |
my $controlChannel = $ecaccess->getControlChannel(); |
| 46 |
|
| 47 |
# Delete the event |
| 48 |
$controlChannel->grantEvent( |
| 49 |
$token, |
| 50 |
$eventid, |
| 51 |
SOAP::Data->name( |
| 52 |
"request" => \SOAP::Data->value( |
| 53 |
SOAP::Data->name( 'userList' => $userList ), |
| 54 |
SOAP::Data->name( 'subscribe' => $opt{subscribe} ? 'true' : 'false' )->type('xsd:boolean'), |
| 55 |
SOAP::Data->name( 'notify' => $opt{notify} ? 'true' : 'false' )->type('xsd:boolean') |
| 56 |
) |
| 57 |
) |
| 58 |
); |
| 59 |
|
| 60 |
# Logout |
| 61 |
END { |
| 62 |
$ecaccess->releaseToken($token) if ($token); |
| 63 |
} |
| 64 |
|
| 65 |
__END__ |
| 66 |
|
| 67 |
=head1 NAME |
| 68 |
|
| 69 |
ecaccess-event-grant - Grant usage of an ECaccess Event |
| 70 |
|
| 71 |
=head1 SYNOPSIS |
| 72 |
|
| 73 |
B<ecaccess-event-grant -version|-help|-manual> |
| 74 |
|
| 75 |
B<ecaccess-event-grant [-debug] [-subscribe] [-notify]> I<event-id> I<user-list> |
| 76 |
|
| 77 |
=head1 DESCRIPTION |
| 78 |
|
| 79 |
Allow managing the Event permissions for a list of user(s). |
| 80 |
|
| 81 |
The permissions can be either subscribe, notify, both or none. In order to remove permissions |
| 82 |
to an Event for a list of users use this command with no B<-subscribe> and B<-notify> options. |
| 83 |
|
| 84 |
=head1 ARGUMENTS |
| 85 |
|
| 86 |
=over 8 |
| 87 |
|
| 88 |
=item I<event-id> |
| 89 |
|
| 90 |
The identifier of the Event to grant. |
| 91 |
|
| 92 |
=item I<user-list> |
| 93 |
|
| 94 |
The user(s) to give/remove the permissions. Multiple users should be separated by a column (e.g. abc,def). |
| 95 |
|
| 96 |
=back |
| 97 |
|
| 98 |
=head1 OPTIONS |
| 99 |
|
| 100 |
=over 8 |
| 101 |
|
| 102 |
=item B<-subscribe> |
| 103 |
|
| 104 |
The user(s) specified in the I<user-list> will be allowed to subscribe to the I<event-id> |
| 105 |
(e.g. with the B<-eventIds> option of the B<ecaccess-job-submit> command). |
| 106 |
|
| 107 |
=item B<-notify> |
| 108 |
|
| 109 |
The user(s) specified in the I<user-list> will be allowed to send notifications to the I<event-id> |
| 110 |
(e.g. with the B<ecaccess-event-send> command). |
| 111 |
|
| 112 |
=item B<-version> |
| 113 |
|
| 114 |
Display version number and exits. |
| 115 |
|
| 116 |
=item B<-help> |
| 117 |
|
| 118 |
Print a brief help message and exits. |
| 119 |
|
| 120 |
=item B<-manual> |
| 121 |
|
| 122 |
Prints the manual page and exits. |
| 123 |
|
| 124 |
=item B<-retry> I<count> |
| 125 |
|
| 126 |
Number of SSL connection retries per 5s to ECMWF. This parameter only apply to the |
| 127 |
initial SSL connection initiated by the command to the ECMWF server. It does not |
| 128 |
apply to all the subsequent requests made afteward as it is mainly targeting errors |
| 129 |
that can happen from time to time during the SSL handshake. Default is no retry. |
| 130 |
|
| 131 |
=item B<-debug> |
| 132 |
|
| 133 |
Display the SOAP and SSL messages exchanged. |
| 134 |
|
| 135 |
=back |
| 136 |
|
| 137 |
=head1 EXAMPLES |
| 138 |
|
| 139 |
B<ecaccess-event-grant -subscribe> I<167> I<abc,def,jhi> |
| 140 |
|
| 141 |
Allow the users I<abc>, I<def> and I<jhi> to subscribe to this Event. |
| 142 |
|
| 143 |
B<ecaccess-event-grant> I<167> I<jkl> |
| 144 |
|
| 145 |
Remove all rights to the Event for the user I<jkl>. |
| 146 |
|
| 147 |
=head1 SEE ALSO |
| 148 |
|
| 149 |
B<ecaccess-event-clear>, B<ecaccess-event-delete>, B<ecaccess-event-send>, B<ecaccess-event-list>, |
| 150 |
B<ecaccess-event-create> and B<ecaccess>. |
| 151 |
|
| 152 |
=cut |