line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Clustericious::Client::Meta; |
2
|
|
|
|
|
|
|
|
3
|
27
|
|
|
27
|
|
5860
|
use strict; |
|
27
|
|
|
|
|
63
|
|
|
27
|
|
|
|
|
739
|
|
4
|
27
|
|
|
27
|
|
162
|
use warnings; |
|
27
|
|
|
|
|
58
|
|
|
27
|
|
|
|
|
11525
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: simple meta object for constructing clients |
7
|
|
|
|
|
|
|
our $VERSION = '1.27'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our %Routes; # hash from class name to array ref of routes. |
10
|
|
|
|
|
|
|
our %RouteAttributes; # hash from class name to hash ref of attributes. |
11
|
|
|
|
|
|
|
our %Objects; # hash from class name to array ref of objects. |
12
|
|
|
|
|
|
|
our @CommonRoutes = ( [ "version" => '' ], [ "status" => '' ], [ "api" => '' ], [ "logtail" => '' ] ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub add_route { # Keep track of routes that have are added. |
16
|
21
|
|
|
21
|
1
|
112
|
my $class = shift; |
17
|
21
|
|
|
|
|
34
|
my $for = shift; # e.g. Restmd::Client |
18
|
21
|
|
|
|
|
33
|
my $route_name = shift; # same as $subname |
19
|
21
|
|
100
|
|
|
182
|
my $route_doc = shift || ''; |
20
|
|
|
|
|
|
|
|
21
|
21
|
100
|
|
|
|
39
|
if (my ($found) = grep { $_->[0] eq $route_name } @{ $Routes{$for} }) { |
|
33
|
|
|
|
|
69
|
|
|
21
|
|
|
|
|
79
|
|
22
|
2
|
|
|
|
|
5
|
$found->[1] = $route_doc; |
23
|
2
|
|
|
|
|
6
|
return; |
24
|
|
|
|
|
|
|
} |
25
|
19
|
|
|
|
|
38
|
push @{ $Routes{$for} }, [ $route_name => $route_doc ]; |
|
19
|
|
|
|
|
74
|
|
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub get_route_doc { |
30
|
2
|
|
|
2
|
1
|
17
|
my $class = shift; |
31
|
2
|
|
|
|
|
4
|
my $for = shift; # e.g. Restmd::Client |
32
|
2
|
|
|
|
|
4
|
my $route_name = shift; # same as $subname |
33
|
2
|
|
|
|
|
4
|
my ($found) = grep { $_->[0] eq $route_name } @{ $Routes{$for} }; |
|
10
|
|
|
|
|
21
|
|
|
2
|
|
|
|
|
7
|
|
34
|
2
|
|
|
|
|
12
|
return $found->[1]; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub add_route_attribute { |
39
|
49
|
|
|
49
|
1
|
564
|
my $class = shift; |
40
|
49
|
|
|
|
|
180
|
my $for = shift; # e.g. Restmd::Client |
41
|
49
|
|
|
|
|
74
|
my $route_name = shift; |
42
|
49
|
|
|
|
|
71
|
my $attr_name = shift; |
43
|
49
|
|
|
|
|
72
|
my $attr_value = shift; |
44
|
49
|
|
|
|
|
187
|
$RouteAttributes{$for}->{$route_name}{$attr_name} = $attr_value; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub get_route_attribute { |
49
|
49
|
|
|
49
|
1
|
371
|
my $class = shift; |
50
|
49
|
|
|
|
|
69
|
my $for = shift; # e.g. Restmd::Client |
51
|
49
|
|
|
|
|
72
|
my $route_name = shift; |
52
|
49
|
|
|
|
|
68
|
my $attr_name = shift; |
53
|
49
|
|
|
|
|
246
|
return $RouteAttributes{$for}->{$route_name}{$attr_name}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub add_object { |
58
|
1
|
|
|
1
|
1
|
4
|
my $class = shift; |
59
|
1
|
|
|
|
|
2
|
my $for = shift; |
60
|
1
|
|
|
|
|
2
|
my $obj_name = shift; |
61
|
1
|
|
50
|
|
|
5
|
my $obj_doc = shift || ''; |
62
|
1
|
|
|
|
|
2
|
push @{ $Objects{$for} }, [ $obj_name => $obj_doc ]; |
|
1
|
|
|
|
|
13
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub routes { |
67
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
68
|
0
|
|
|
|
|
|
my $for = shift; |
69
|
0
|
0
|
|
|
|
|
return [ @CommonRoutes, @{$Routes{$for} || []}]; |
|
0
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub objects { |
73
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
74
|
0
|
|
|
|
|
|
my $for = shift; |
75
|
0
|
|
|
|
|
|
return $Objects{$for}; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=pod |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=encoding UTF-8 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 NAME |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Clustericious::Client::Meta - simple meta object for constructing clients |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 VERSION |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
version 1.27 |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 METHODS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 add_route |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Add or replace documentation about a route. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Parameters : |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=over 4 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item the name of the client class |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item the name of the route |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item documentation about the route's arguments |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=back |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 get_route_doc |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
$meta->get_route_doc($class,$route_name); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Get documentation for a route. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 add_route_attribute |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Add an attribute for a route. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Parameters : |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=over 4 |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item the name of the attribute |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item the value of the attribute. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=back |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Recognized attributes : |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=over 4 |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item dont_read_files : if set, no attempt will be made to treat arguments as yaml files. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item auto_failover : if set, when a connection fails and does not return a status code, each url in the list of configured failover_url's will be tried in turn. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=back |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 get_route_attribute |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Like the above but retrieve an attribute. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 add_object |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Add an object. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Parameters : |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=over 4 |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item the name of the client class |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item the name of the object |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item documentation about the object. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=back |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 routes, objects |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Return an array ref of routes/objects. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Each element is a two element array; the |
168
|
|
|
|
|
|
|
first element is the name, the second is |
169
|
|
|
|
|
|
|
documentation. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 SEE ALSO |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
L<Clustericious::Client>, L<Clustericious> |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 AUTHOR |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Original author: Brian Duggan |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Current maintainer: Graham Ollis E<lt>plicease@cpan.orgE<gt> |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Contributors: |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Curt Tilmes |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Yanick Champoux |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
This software is copyright (c) 2013 by NASA GSFC. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
192
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=cut |