line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Megaport::Internal::_Result; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
1111
|
use 5.10.0; |
|
3
|
|
|
|
|
9
|
|
4
|
3
|
|
|
3
|
|
10
|
use strict; |
|
3
|
|
|
|
|
2
|
|
|
3
|
|
|
|
|
54
|
|
5
|
3
|
|
|
3
|
|
10
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
63
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
7
|
use Carp qw(croak cluck); |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
156
|
|
8
|
3
|
|
|
3
|
|
28
|
use List::Util qw(first); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
226
|
|
9
|
3
|
|
|
3
|
|
937
|
use Megaport::Internal::_Obj; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
84
|
|
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
|
|
17
|
use Class::Tiny qw(client errstr), { |
12
|
|
|
|
|
|
|
_data => {} |
13
|
3
|
|
|
3
|
|
11
|
}; |
|
3
|
|
|
|
|
3
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub BUILD { |
16
|
0
|
|
|
0
|
0
|
|
my ($self, $args) = @_; |
17
|
|
|
|
|
|
|
|
18
|
0
|
0
|
|
|
|
|
croak __PACKAGE__ . '->new: client not passed to constructor' unless $self->client; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $data = $self->client->request($self->_request->{method} => $self->_request->{path}); |
21
|
|
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
|
if ($data) { |
23
|
0
|
|
|
|
|
|
my %list; |
24
|
0
|
|
|
|
|
|
foreach (@{$data}) { |
|
0
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
$list{$_->{ $self->_request->{pkey} }} = Megaport::Internal::_Obj->new(%{$_}); |
|
0
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$self->_data(\%list); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub get { |
33
|
0
|
|
|
0
|
1
|
|
my ($self, %search) = @_; |
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
0
|
|
|
|
if ($search{id} && exists $self->_data->{$search{id}}) { |
36
|
0
|
|
|
|
|
|
return $self->_data->{$search{id}}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $needle = first { |
40
|
0
|
|
|
0
|
|
|
foreach my $k (keys %search) { |
41
|
0
|
0
|
|
|
|
|
last unless exists $_->{$k}; |
42
|
0
|
0
|
|
|
|
|
return $_ if $_->{$k} eq $search{$k}; |
43
|
|
|
|
|
|
|
} |
44
|
0
|
|
|
|
|
|
} values %{$self->_data}; |
|
0
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
return $needle; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub list { |
50
|
0
|
|
|
0
|
1
|
|
my ($self, %search) = @_; |
51
|
0
|
|
|
|
|
|
my @result; |
52
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
if (!%search) { |
54
|
0
|
|
|
|
|
|
@result = values %{$self->_data}; |
|
0
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
else { |
57
|
0
|
|
|
|
|
|
foreach my $item (values %{$self->_data}) { |
|
0
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
foreach my $k (keys %search) { |
59
|
0
|
0
|
|
|
|
|
if (ref $search{$k} eq 'Regexp') { |
60
|
0
|
0
|
|
|
|
|
push @result, $item if $item->{$k} =~ $search{$k}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
else { |
63
|
0
|
0
|
|
|
|
|
push @result, $item if $item->{$k} eq $search{$k}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
|
return wantarray ? @result : \@result; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
__END__ |