| 1 |
#!/usr/bin/perl -w |
| 2 |
# |
| 3 |
# ecaccess-event-list: List available events |
| 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 = ( 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 |
version |
| 18 |
help|? |
| 19 |
manual |
| 20 |
retry=i |
| 21 |
debug |
| 22 |
) |
| 23 |
); |
| 24 |
|
| 25 |
# Display version if requested |
| 26 |
die ECMWF::ECaccess->VERSION . "\n" if ( $opt{version} ); |
| 27 |
|
| 28 |
pod2usage( -noperldoc => 1, -exit => 1, verbose => 1 ) if ( $opt{help} ); |
| 29 |
pod2usage( -noperldoc => 1, -exit => 1, verbose => 2 ) if ( $opt{manual} ); |
| 30 |
|
| 31 |
my $eventidorname = $ARGV[0]; |
| 32 |
|
| 33 |
# Create the ECaccess Controler |
| 34 |
my $ecaccess = ECMWF::ECaccess->new( $opt{retry}, $opt{debug}); |
| 35 |
|
| 36 |
# Get the Token (using the Certificate in $HOME) |
| 37 |
my $token = $ecaccess->getToken(); |
| 38 |
|
| 39 |
# Get the Control Channel |
| 40 |
my $controlChannel = $ecaccess->getControlChannel(); |
| 41 |
|
| 42 |
if ( not($eventidorname) ) { |
| 43 |
|
| 44 |
# Get the list of events |
| 45 |
my $events = $controlChannel->getEventList($token); |
| 46 |
|
| 47 |
# Display the information for each event |
| 48 |
foreach $event ( $events->valueof('//getEventListResponse/return') ) { |
| 49 |
printf "%-10s %-20s %-40s\n", $event->{eventId}, $event->{name}, $event->{comment}; |
| 50 |
} |
| 51 |
} |
| 52 |
else { |
| 53 |
|
| 54 |
# Get the information for the specified event |
| 55 |
my $event = $controlChannel->getEvent( $token, $eventidorname )->valueof('//getEventResponse/return'); |
| 56 |
print " Event-id: ", $event->{eventId}, "\n"; |
| 57 |
print " Name: ", $event->{name}, "\n"; |
| 58 |
print " Public: ", ( $event->{isPublic} eq 'true' ? 'yes' : 'no' ), "\n"; |
| 59 |
print " Owner: ", $event->{ownerUserId}, "\n"; |
| 60 |
print " Comment: ", $event->{comment}, "\n" if $event->{comment}; |
| 61 |
print " Title: ", $event->{title}, "\n" if $event->{title}; |
| 62 |
print " Metadata: ", $event->{metadata}, "\n" if $event->{metadata}; |
| 63 |
print " Can send: ", $event->{notifyUserList}, "\n" if $event->{notifyUserList}; |
| 64 |
print "Can subscribe: ", $event->{subscribeUserList}, "\n" if $event->{subscribeUserList}; |
| 65 |
} |
| 66 |
|
| 67 |
# Logout |
| 68 |
END { |
| 69 |
$ecaccess->releaseToken($token) if ($token); |
| 70 |
} |
| 71 |
|
| 72 |
__END__ |
| 73 |
|
| 74 |
=head1 NAME |
| 75 |
|
| 76 |
ecaccess-event-list - List available events |
| 77 |
|
| 78 |
=head1 SYNOPSIS |
| 79 |
|
| 80 |
B<ecaccess-event-list -version|-help|-manual> |
| 81 |
|
| 82 |
B<ecaccess-event-list [-debug] [>I<event-id>|I<event-name>B<]> |
| 83 |
|
| 84 |
=head1 DESCRIPTION |
| 85 |
|
| 86 |
List all the ECaccess Events which are available to your ECMWF user identifier. If an |
| 87 |
I<event-id> or I<event-name> is specified as an argument then this command |
| 88 |
will display all the information related to this event. |
| 89 |
|
| 90 |
=head1 ARGUMENTS |
| 91 |
|
| 92 |
=over 8 |
| 93 |
|
| 94 |
=item I<event-id>|I<event-name> (optional) |
| 95 |
|
| 96 |
The identifier or name of the Event to retrieve the details. |
| 97 |
|
| 98 |
=back |
| 99 |
|
| 100 |
=head1 OPTIONS |
| 101 |
|
| 102 |
=over 8 |
| 103 |
|
| 104 |
=item B<-version> |
| 105 |
|
| 106 |
Display version number and exits. |
| 107 |
|
| 108 |
=item B<-help> |
| 109 |
|
| 110 |
Print a brief help message and exits. |
| 111 |
|
| 112 |
=item B<-manual> |
| 113 |
|
| 114 |
Prints the manual page and exits. |
| 115 |
|
| 116 |
=item B<-retry> I<count> |
| 117 |
|
| 118 |
Number of SSL connection retries per 5s to ECMWF. This parameter only apply to the |
| 119 |
initial SSL connection initiated by the command to the ECMWF server. It does not |
| 120 |
apply to all the subsequent requests made afteward as it is mainly targeting errors |
| 121 |
that can happen from time to time during the SSL handshake. Default is no retry. |
| 122 |
|
| 123 |
=item B<-debug> |
| 124 |
|
| 125 |
Display the SOAP and SSL messages exchanged. |
| 126 |
|
| 127 |
=back |
| 128 |
|
| 129 |
=head1 EXAMPLES |
| 130 |
|
| 131 |
B<ecaccess-event-list> I<an00h000> |
| 132 |
|
| 133 |
Gives the information related to the I<event-name> I<an00h000>. |
| 134 |
|
| 135 |
B<ecaccess-event-list> |
| 136 |
|
| 137 |
List all the events available to your ECMWF user identifier. |
| 138 |
|
| 139 |
=head1 SEE ALSO |
| 140 |
|
| 141 |
B<ecaccess-event-grant>, B<ecaccess-event-clear>, B<ecaccess-event-send>, B<ecaccess-event-delete>, |
| 142 |
B<ecaccess-event-create> and B<ecaccess>. |
| 143 |
|
| 144 |
=cut |