Debian Codegraph @

script/ecaccess-certificate-list

raw
1 #!/usr/bin/perl -w
2 #
3 # ecaccess-certificate-list: List Available Operations
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 $operationname = $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($operationname) ) {
43
44 # Get the list of operations
45 my $operations = $controlChannel->getOperationList($token);
46
47 # Display the information for each operation
48 foreach $operation ( $operations->valueof('//getOperationListResponse/return') ) {
49 printf "%-20s %-8s %-20s %-20s\n", $operation->{name}, $operation->{duration}, $operation->{endDate}, $operation->{comment};
50 }
51 }
52 else {
53
54 # Get the information for the specified operation
55 $operation = $controlChannel->getOperation( $token, $operationname )->valueof('//getOperationResponse/return');
56 print " Operation name: ", $operation->{name}, "\n";
57 print "Standard Validity: ", $operation->{standard}, "\n";
58 print " Your Validity: ", $operation->{duration}, "\n";
59 print " Start Date: ", $operation->{startDate}, "\n";
60 print " End Date: ", $operation->{endDate}, "\n";
61 print " Comment: ", $operation->{comment}, "\n";
62 }
63
64 # Logout
65 END {
66 $ecaccess->releaseToken($token) if ($token);
67 }
68
69 __END__
70
71 =head1 NAME
72
73 ecaccess-certificate-list - List Available Operations
74
75 =head1 SYNOPSIS
76
77 B<ecaccess-certificate-list -version|-help|-manual>
78
79 B<ecaccess-certificate-list [-debug] [>I<operation-name>B<]>
80
81 =head1 DESCRIPTION
82
83 List all the Operations which are available with the current Certificate (the one
84 in your "$HOME/.eccert.crt" File). If a required Operation is expired then you should
85 renew your Certificate with the B<ecaccess-certificate-create> command. If you specify
86 an I<operation-name> on the command-line then the information for this Operation only
87 will be displayed.
88
89 =head1 ARGUMENTS
90
91 =over 8
92
93 =item <operation-name> (optional)
94
95 The name of the Operation to retrieve the details.
96
97 =back
98
99 =head1 OPTIONS
100
101 =over 8
102
103 =item B<-version>
104
105 Display version number and exits.
106
107 =item B<-help>
108
109 Print a brief help message and exits.
110
111 =item B<-manual>
112
113 Prints the manual page and exits.
114
115 =item B<-retry> I<count>
116
117 Number of SSL connection retries per 5s to ECMWF. This parameter only apply to the
118 initial SSL connection initiated by the command to the ECMWF server. It does not
119 apply to all the subsequent requests made afteward as it is mainly targeting errors
120 that can happen from time to time during the SSL handshake. Default is no retry.
121
122 =item B<-debug>
123
124 Display the SOAP and SSL messages exchanged.
125
126 =back
127
128 =head1 EXAMPLES
129
130 B<ecaccess-certificate-list>
131
132 List all the Operations for your certificate.
133
134 B<ecaccess-certificate-list> I<submitJob>
135
136 List all the details for the Operation I<submitJob> only.
137
138 =head1 SEE ALSO
139
140 B<ecaccess-certificate-create> and B<ecaccess>.
141
142 =cut