line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Paws::Net::QueryCaller; |
2
|
13
|
|
|
13
|
|
159050
|
use Moose::Role; |
|
13
|
|
|
|
|
58
|
|
|
13
|
|
|
|
|
100
|
|
3
|
13
|
|
|
13
|
|
63199
|
use HTTP::Request::Common; |
|
13
|
|
|
|
|
77178
|
|
|
13
|
|
|
|
|
854
|
|
4
|
13
|
|
|
13
|
|
88
|
use POSIX qw(strftime); |
|
13
|
|
|
|
|
25
|
|
|
13
|
|
|
|
|
90
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub array_flatten_string { |
7
|
18
|
|
|
18
|
0
|
30
|
my $self = shift; |
8
|
18
|
100
|
|
|
|
48
|
return ($self->flattened_arrays)?'%s.%d':'%s.member.%d'; |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# converts the objects that represent the call into parameters that the API can understand |
12
|
|
|
|
|
|
|
sub _to_querycaller_params { |
13
|
24
|
|
|
24
|
|
65
|
my ($self, $params) = @_; |
14
|
24
|
|
|
|
|
43
|
my %p; |
15
|
24
|
|
|
|
|
93
|
foreach my $att (grep { $_ !~ m/^_/ } $params->meta->get_attribute_list) { |
|
101
|
|
|
|
|
787
|
|
16
|
101
|
100
|
|
|
|
260
|
my $key = $params->meta->get_attribute($att)->does('Paws::API::Attribute::Trait::NameInRequest')?$params->meta->get_attribute($att)->request_name:$att; |
17
|
101
|
100
|
|
|
|
11914
|
if (defined $params->$att) { |
18
|
51
|
|
|
|
|
136
|
my $att_type = $params->meta->get_attribute($att)->type_constraint; |
19
|
|
|
|
|
|
|
|
20
|
51
|
100
|
|
|
|
2777
|
if ($self->_is_internal_type($att_type)) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
21
|
33
|
100
|
|
|
|
1540
|
if ($att_type eq 'Bool') { |
22
|
1
|
50
|
|
|
|
51
|
$p{ $key } = ($params->{$att} == 1) ? 'true' : 'false'; |
23
|
|
|
|
|
|
|
} else { |
24
|
32
|
|
|
|
|
976
|
$p{ $key } = $params->{$att}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} elsif ($att_type =~ m/^ArrayRef\[(.*)\]/) { |
27
|
8
|
100
|
|
|
|
1445
|
if ($self->_is_internal_type("$1")){ |
28
|
6
|
|
|
|
|
13
|
my $i = 1; |
29
|
6
|
|
|
|
|
15
|
foreach my $value (@{ $params->$att }){ |
|
6
|
|
|
|
|
155
|
|
30
|
8
|
|
|
|
|
35
|
$p{ sprintf($self->array_flatten_string, $key, $i) } = $value; |
31
|
8
|
|
|
|
|
29
|
$i++ |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} else { |
34
|
2
|
|
|
|
|
5
|
my $i = 1; |
35
|
2
|
|
|
|
|
7
|
foreach my $value (@{ $params->$att }){ |
|
2
|
|
|
|
|
51
|
|
36
|
3
|
|
|
|
|
22
|
my %complex_value = $self->_to_querycaller_params($value); |
37
|
3
|
|
|
|
|
12
|
map { $p{ sprintf($self->array_flatten_string . ".%s", $key, $i, $_) } = $complex_value{$_} } keys %complex_value; |
|
10
|
|
|
|
|
24
|
|
38
|
3
|
|
|
|
|
12
|
$i++ |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} elsif ($params->$att->does('Paws::API::StrToObjMapParser')) { |
42
|
1
|
|
|
|
|
183
|
my $i = 1; |
43
|
1
|
|
|
|
|
3
|
foreach my $map_key (keys %{ $params->$att->Map }){ |
|
1
|
|
|
|
|
29
|
|
44
|
1
|
|
|
|
|
16
|
$p{ "$key.$i.Name" } = $map_key; |
45
|
1
|
|
|
|
|
29
|
my %complex_value = $self->_to_querycaller_params($params->$att->Map->{ $map_key }); |
46
|
1
|
|
|
|
|
4
|
map { $p{ "$key.$i.Value.$_" } = $complex_value{$_} } keys %complex_value; |
|
2
|
|
|
|
|
9
|
|
47
|
1
|
|
|
|
|
4
|
$i++; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} elsif ($params->$att->does('Paws::API::StrToNativeMapParser')) { |
50
|
1
|
|
|
|
|
247
|
my $i = 1; |
51
|
1
|
|
|
|
|
3
|
foreach my $map_key (keys %{ $params->$att->Map }){ |
|
1
|
|
|
|
|
34
|
|
52
|
1
|
|
|
|
|
7
|
$p{ "$key.entry.$i.key" } = $map_key; |
53
|
1
|
|
|
|
|
29
|
$p{ "$key.entry.$i.value" } = $params->$att->Map->{ $map_key }; |
54
|
1
|
|
|
|
|
4
|
$i++; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} elsif ($params->$att->does('Paws::API::MapParser')){ |
57
|
1
|
|
|
|
|
162
|
my $i = 1; |
58
|
1
|
|
|
|
|
22
|
foreach my $map_key (sort $params->$att->meta->get_attribute_list){ |
59
|
18
|
100
|
|
|
|
384
|
next if (not defined $params->$att->$map_key); |
60
|
3
|
|
|
|
|
10
|
$p{ "$key.$i.Name" } = $map_key; |
61
|
3
|
|
|
|
|
60
|
$p{ "$key.$i.Value" } = $params->$att->$map_key; |
62
|
3
|
|
|
|
|
7
|
$i++; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} else { |
65
|
7
|
|
|
|
|
1489
|
my %complex_value = $self->_to_querycaller_params($params->$att); |
66
|
7
|
|
|
|
|
15
|
map { $p{ "$key.$_" } = $complex_value{$_} } keys %complex_value; |
|
8
|
|
|
|
|
40
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
24
|
|
|
|
|
464
|
return %p; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub generate_content_from_parameters { |
74
|
13
|
|
|
13
|
0
|
42
|
my ($self, $request) = @_; |
75
|
|
|
|
|
|
|
|
76
|
13
|
|
|
|
|
362
|
$request->headers->content_type('application/x-www-form-urlencoded'); |
77
|
13
|
|
|
|
|
250
|
my $url = URI->new('http:'); |
78
|
13
|
|
|
|
|
1282
|
$url->query_form($request->parameters); |
79
|
13
|
|
|
|
|
2426
|
my $content = $url->query; |
80
|
|
|
|
|
|
|
# HTML/4.01 says that line breaks are represented as "CR LF" pairs (i.e., `%0D%0A') |
81
|
13
|
50
|
|
|
|
160
|
$content =~ s/(?<!%0D)%0A/%0D%0A/g if (defined $content); |
82
|
13
|
|
|
|
|
384
|
return $content; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub prepare_request_for_call { |
86
|
13
|
|
|
13
|
0
|
140
|
my ($self, $call) = @_; |
87
|
|
|
|
|
|
|
|
88
|
13
|
|
|
|
|
108
|
my $request = Paws::Net::APIRequest->new(); |
89
|
|
|
|
|
|
|
|
90
|
13
|
|
|
|
|
8413
|
$request->url($self->_api_endpoint . '/'); |
91
|
13
|
|
|
|
|
297
|
$request->uri('/'); |
92
|
13
|
|
|
|
|
406
|
$request->method('POST'); |
93
|
|
|
|
|
|
|
|
94
|
13
|
|
|
|
|
368
|
$request->parameters({ Action => $call->_api_call, |
95
|
|
|
|
|
|
|
Version => $self->version, |
96
|
|
|
|
|
|
|
$self->_to_querycaller_params($call) |
97
|
|
|
|
|
|
|
}); |
98
|
|
|
|
|
|
|
|
99
|
13
|
50
|
|
|
|
84
|
if (not $self->does('Paws::Net::V2Signature')){ |
100
|
13
|
|
|
|
|
6386
|
$request->content($self->generate_content_from_parameters($request)); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
13
|
|
|
|
|
85
|
$self->sign($request); |
104
|
|
|
|
|
|
|
|
105
|
13
|
|
|
|
|
466
|
return $request; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
1; |