| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
2
|
|
|
2
|
|
52662
|
use strict; |
|
|
2
|
|
|
|
|
10
|
|
|
|
2
|
|
|
|
|
53
|
|
|
2
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
94
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Footprintless::Plugin::Atlassian::Confluence::RequestBuilder; |
|
5
|
|
|
|
|
|
|
$Footprintless::Plugin::Atlassian::Confluence::RequestBuilder::VERSION = '1.03'; |
|
6
|
|
|
|
|
|
|
# ABSTRACT: A request builder for the Atlassian Confluence REST API |
|
7
|
|
|
|
|
|
|
# PODNAME: Footprintless::Plugin::Atlassian::Confluence::RequestBuilder |
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
354
|
use HTTP::Request; |
|
|
2
|
|
|
|
|
18340
|
|
|
|
2
|
|
|
|
|
45
|
|
|
10
|
2
|
|
|
2
|
|
969
|
use JSON; |
|
|
2
|
|
|
|
|
14243
|
|
|
|
2
|
|
|
|
|
9
|
|
|
11
|
2
|
|
|
2
|
|
561
|
use Log::Any; |
|
|
2
|
|
|
|
|
6381
|
|
|
|
2
|
|
|
|
|
9
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $logger = Log::Any->get_logger(); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
|
16
|
2
|
|
|
2
|
1
|
11206
|
return bless( {}, shift )->_init(@_); |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub create_content { |
|
20
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $content, %options ) = @_; |
|
21
|
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
0
|
return HTTP::Request->new( |
|
23
|
|
|
|
|
|
|
'POST', |
|
24
|
|
|
|
|
|
|
$self->_url( "/rest/api/content", %options ), |
|
25
|
|
|
|
|
|
|
[ 'Content-Type' => 'application/json' ], |
|
26
|
|
|
|
|
|
|
encode_json($content) |
|
27
|
|
|
|
|
|
|
); |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub delete_content { |
|
31
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $id ) = @_; |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
0
|
return HTTP::Request->new( 'DELETE', $self->_url("/rest/api/content/$id") ); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub get_content { |
|
37
|
5
|
|
|
5
|
1
|
8268
|
my ( $self, %options ) = @_; |
|
38
|
|
|
|
|
|
|
|
|
39
|
5
|
|
|
|
|
11
|
my $id = delete( $options{id} ); |
|
40
|
5
|
100
|
|
|
|
26
|
return HTTP::Request->new( 'GET', |
|
41
|
|
|
|
|
|
|
$id |
|
42
|
|
|
|
|
|
|
? $self->_url( "/rest/api/content/$id", %options ) |
|
43
|
|
|
|
|
|
|
: $self->_url( "/rest/api/content", %options ) ); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub get_content_children { |
|
47
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $id, %options ) = @_; |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
0
|
my $type = delete( $options{type} ); |
|
50
|
0
|
0
|
|
|
|
0
|
return HTTP::Request->new( 'GET', |
|
51
|
|
|
|
|
|
|
$type |
|
52
|
|
|
|
|
|
|
? $self->_url( "/rest/api/content/$id/child/$type", %options ) |
|
53
|
|
|
|
|
|
|
: $self->_url( "/rest/api/content/$id/child", %options ) ); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _init { |
|
57
|
2
|
|
|
2
|
|
6
|
my ( $self, $base_url ) = @_; |
|
58
|
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
10
|
$self->{base_url} = $base_url; |
|
60
|
|
|
|
|
|
|
|
|
61
|
2
|
|
|
|
|
7
|
return $self; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub update_content { |
|
65
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $id, $content, %options ) = @_; |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
return HTTP::Request->new( |
|
68
|
|
|
|
|
|
|
'PUT', |
|
69
|
|
|
|
|
|
|
$self->_url( "/rest/api/content/$id", %options ), |
|
70
|
|
|
|
|
|
|
[ 'Content-Type' => 'application/json' ], |
|
71
|
|
|
|
|
|
|
encode_json($content) |
|
72
|
|
|
|
|
|
|
); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _url { |
|
76
|
5
|
|
|
5
|
|
14
|
my ( $self, $path, %query_params ) = @_; |
|
77
|
|
|
|
|
|
|
|
|
78
|
5
|
|
|
|
|
12
|
my $url = "$self->{base_url}$path"; |
|
79
|
5
|
100
|
|
|
|
15
|
if (%query_params) { |
|
80
|
3
|
|
|
|
|
14
|
require URI::Escape; |
|
81
|
3
|
|
|
|
|
8
|
my @query_string = (); |
|
82
|
3
|
|
|
|
|
12
|
foreach my $key ( sort( keys(%query_params) ) ) { |
|
83
|
6
|
100
|
|
|
|
82
|
push( @query_string, ( @query_string ? '&' : '?' ) ); |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
push( |
|
86
|
|
|
|
|
|
|
@query_string, |
|
87
|
|
|
|
|
|
|
join( |
|
88
|
|
|
|
|
|
|
'&', |
|
89
|
6
|
|
|
|
|
14
|
map { URI::Escape::uri_escape($key) . '=' . URI::Escape::uri_escape($_) } ( |
|
90
|
|
|
|
|
|
|
ref( $query_params{$key} ) eq 'ARRAY' |
|
91
|
0
|
|
|
|
|
0
|
? @{ $query_params{$key} } |
|
92
|
6
|
50
|
|
|
|
16
|
: ( $query_params{$key} ) |
|
93
|
|
|
|
|
|
|
) |
|
94
|
|
|
|
|
|
|
) |
|
95
|
|
|
|
|
|
|
); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
3
|
50
|
|
|
|
93
|
$url .= ( @query_string ? join( '', @query_string ) : '' ); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
5
|
|
|
|
|
28
|
return $url; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |