| 1 |
#!/usr/bin/perl -w |
| 2 |
# |
| 3 |
# ecaccess-event-send: Create 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 = ( comment => '', public => 0, overwrite => 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 |
comment:s |
| 18 |
public |
| 19 |
overwrite |
| 20 |
version |
| 21 |
help|? |
| 22 |
manual |
| 23 |
retry=i |
| 24 |
debug |
| 25 |
) |
| 26 |
); |
| 27 |
|
| 28 |
# Display version if requested |
| 29 |
die ECMWF::ECaccess->VERSION . "\n" if ( $opt{version} ); |
| 30 |
|
| 31 |
my $eventname = $ARGV[0]; |
| 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-name specified!\n" ) if not($eventname); |
| 36 |
|
| 37 |
# Create the ECaccess Controler |
| 38 |
my $ecaccess = ECMWF::ECaccess->new( $opt{retry}, $opt{debug}); |
| 39 |
|
| 40 |
# Get the Token (using the Certificate in $HOME) |
| 41 |
my $token = $ecaccess->getToken(); |
| 42 |
|
| 43 |
# Get the Control Channel |
| 44 |
my $controlChannel = $ecaccess->getControlChannel(); |
| 45 |
|
| 46 |
# Create the event |
| 47 |
my $event = $controlChannel->createEvent( |
| 48 |
$token, |
| 49 |
SOAP::Data->name( |
| 50 |
"request" => \SOAP::Data->value( |
| 51 |
SOAP::Data->name( 'name' => $eventname ), |
| 52 |
SOAP::Data->name( 'comment' => $opt{comment} ), |
| 53 |
SOAP::Data->name( 'overwrite' => $opt{overwrite} ? 'true' : 'false' )->type('xsd:boolean'), |
| 54 |
SOAP::Data->name( 'isPublic' => $opt{public} ? 'true' : 'false' )->type('xsd:boolean') |
| 55 |
) |
| 56 |
) |
| 57 |
); |
| 58 |
print $event->valueof('//createEventResponse/return')->{eventId}, "\n"; |
| 59 |
|
| 60 |
# Logout |
| 61 |
END { |
| 62 |
$ecaccess->releaseToken($token) if ($token); |
| 63 |
} |
| 64 |
|
| 65 |
__END__ |
| 66 |
|
| 67 |
=head1 NAME |
| 68 |
|
| 69 |
ecaccess-event-create - Create an ECaccess Event |
| 70 |
|
| 71 |
=head1 SYNOPSIS |
| 72 |
|
| 73 |
B<ecaccess-event-create -version|-help|-manual> |
| 74 |
|
| 75 |
B<ecaccess-event-create [-debug] [-overwrite] [-public] [-comment> I<string>B<]> I<event-name> |
| 76 |
|
| 77 |
=head1 DESCRIPTION |
| 78 |
|
| 79 |
Allow creating an ECaccess Event. As a result the I<event-id> is displayed. |
| 80 |
|
| 81 |
If an event already exists with the same I<event-name> then by default the request is |
| 82 |
rejected (please check the B<-overwrite> option). |
| 83 |
|
| 84 |
By default an event is private and restricted to its owner. Access can however be shared with |
| 85 |
other users thanks to the B<ecaccess-event-grant> command or with the B<-public> option which |
| 86 |
make it visible to all. |
| 87 |
|
| 88 |
=head1 ARGUMENTS |
| 89 |
|
| 90 |
=over 8 |
| 91 |
|
| 92 |
=item I<event-name> |
| 93 |
|
| 94 |
The name of the Event to create. |
| 95 |
|
| 96 |
=back |
| 97 |
|
| 98 |
=head1 OPTIONS |
| 99 |
|
| 100 |
=over 8 |
| 101 |
|
| 102 |
=item B<-overwrite> |
| 103 |
|
| 104 |
Allow deleting an existing event with the same name and create a new one (the |
| 105 |
identifier will be however different to the original one). |
| 106 |
|
| 107 |
=item B<-public> |
| 108 |
|
| 109 |
Allow creating a public event which can be used by everybody. In order to have |
| 110 |
a better tunning of the permissions please keep the event private and use the |
| 111 |
B<ecaccess-event-grant> command instead. |
| 112 |
|
| 113 |
=item B<-comment> I<string> |
| 114 |
|
| 115 |
Specify the I<string> to display as a comment for the event. |
| 116 |
|
| 117 |
=item B<-version> |
| 118 |
|
| 119 |
Display version number and exits. |
| 120 |
|
| 121 |
=item B<-help> |
| 122 |
|
| 123 |
Print a brief help message and exits. |
| 124 |
|
| 125 |
=item B<-manual> |
| 126 |
|
| 127 |
Prints the manual page and exits. |
| 128 |
|
| 129 |
=item B<-retry> I<count> |
| 130 |
|
| 131 |
Number of SSL connection retries per 5s to ECMWF. This parameter only apply to the |
| 132 |
initial SSL connection initiated by the command to the ECMWF server. It does not |
| 133 |
apply to all the subsequent requests made afteward as it is mainly targeting errors |
| 134 |
that can happen from time to time during the SSL handshake. Default is no retry. |
| 135 |
|
| 136 |
=item B<-debug> |
| 137 |
|
| 138 |
Display the SOAP and SSL messages exchanged. |
| 139 |
|
| 140 |
=back |
| 141 |
|
| 142 |
=head1 EXAMPLES |
| 143 |
|
| 144 |
B<ecaccess-event-create -public -comment> I<"My Comment"> I<"My Event Name"> |
| 145 |
|
| 146 |
Create the new event with the name I<"My Event Name"> and the comment I<"My Comment">. This |
| 147 |
new event is public and other users can subscribe to it. |
| 148 |
|
| 149 |
=head1 SEE ALSO |
| 150 |
|
| 151 |
B<ecaccess-event-grant>, B<ecaccess-event-clear>, B<ecaccess-event-send>, B<ecaccess-event-list>, |
| 152 |
B<ecaccess-event-delete> and B<ecaccess>. |
| 153 |
|
| 154 |
=cut |