| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package OpenStack::MetaAPI::Routes; |
|
2
|
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
47
|
use strict; |
|
|
6
|
|
|
|
|
15
|
|
|
|
6
|
|
|
|
|
186
|
|
|
4
|
6
|
|
|
6
|
|
34
|
use warnings; |
|
|
6
|
|
|
|
|
21
|
|
|
|
6
|
|
|
|
|
148
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
3262
|
use Moo; |
|
|
6
|
|
|
|
|
72133
|
|
|
|
6
|
|
|
|
|
35
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
11637
|
use OpenStack::MetaAPI::API (); |
|
|
6
|
|
|
|
|
20
|
|
|
|
6
|
|
|
|
|
134
|
|
|
9
|
6
|
|
|
6
|
|
2694
|
use YAML::XS; |
|
|
6
|
|
|
|
|
17034
|
|
|
|
6
|
|
|
|
|
338
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
6
|
|
|
6
|
|
2732
|
use OpenStack::MetaAPI::Helpers::DataAsYaml; |
|
|
6
|
|
|
|
|
17
|
|
|
|
6
|
|
|
|
|
2687
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'auth' => (is => 'ro'); |
|
14
|
|
|
|
|
|
|
has 'api' => (is => 'ro'); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $ROUTES; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub init_once { |
|
19
|
6
|
|
33
|
6
|
0
|
46
|
$ROUTES //= OpenStack::MetaAPI::Helpers::DataAsYaml::LoadData(); |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# cannot read from data block at compile time |
|
23
|
|
|
|
|
|
|
#INIT { init_once() } |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub list_all { |
|
26
|
6
|
|
|
6
|
0
|
112
|
init_once(); |
|
27
|
6
|
|
|
|
|
115
|
return sort keys %$ROUTES; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
0
|
|
|
sub DESTROY { |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
our $AUTOLOAD; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
36
|
39
|
|
|
39
|
|
40556
|
my (@args) = @_; |
|
37
|
39
|
|
|
|
|
88
|
my $call_for = $AUTOLOAD; |
|
38
|
|
|
|
|
|
|
|
|
39
|
39
|
|
|
|
|
199
|
$call_for =~ s/.*:://; |
|
40
|
|
|
|
|
|
|
|
|
41
|
39
|
50
|
|
|
|
178
|
if (my $route = $ROUTES->{$call_for}) { |
|
42
|
39
|
50
|
|
|
|
128
|
die "$call_for is a method call" unless ref $args[0] eq __PACKAGE__; |
|
43
|
39
|
|
|
|
|
81
|
my $self = shift @args; |
|
44
|
|
|
|
|
|
|
|
|
45
|
39
|
|
|
|
|
123
|
my $service = $self->service($route->{service}); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# not easy to overwrite can if Moo/XS::Accessor |
|
48
|
39
|
|
|
|
|
164
|
my $controller = $service->can_method($call_for); |
|
49
|
|
|
|
|
|
|
|
|
50
|
39
|
50
|
|
|
|
107
|
die "Invalid route '$call_for' for service '" . ref($service) . "'" |
|
51
|
|
|
|
|
|
|
unless defined $controller; |
|
52
|
|
|
|
|
|
|
|
|
53
|
39
|
|
|
|
|
148
|
return $controller->($service, @args); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
0
|
die "Unknown function $call_for from AUTOLOAD"; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub service { |
|
60
|
39
|
|
|
39
|
0
|
98
|
my ($self, $name) = @_; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# cache the service once |
|
63
|
39
|
|
|
|
|
86
|
my $k = '_service_' . $name; |
|
64
|
39
|
100
|
|
|
|
122
|
if (!$self->{$k}) { |
|
65
|
|
|
|
|
|
|
$self->{$k} = OpenStack::MetaAPI::API::get_service( |
|
66
|
|
|
|
|
|
|
name => $name, auth => $self->auth, |
|
67
|
8
|
|
|
|
|
87
|
region => $ENV{'OS_REGION_NAME'}, |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# backreference |
|
70
|
|
|
|
|
|
|
api => $self->api, |
|
71
|
|
|
|
|
|
|
); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
39
|
|
|
|
|
106
|
return $self->{$k}; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
## this data block describes the routes |
|
80
|
|
|
|
|
|
|
# this could be moved to a file... |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=pod |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=encoding UTF-8 |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 NAME |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
OpenStack::MetaAPI::Routes |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 VERSION |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
version 0.001 |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 AUTHOR |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Nicolas R |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This software is copyright (c) 2019 by cPanel, Inc. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
103
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__DATA__ |