line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
13987
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
69
|
|
2
|
2
|
|
|
2
|
|
44
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
89
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Footprintless::Plugin::Atlassian::Confluence::RequestBuilder; |
5
|
|
|
|
|
|
|
$Footprintless::Plugin::Atlassian::Confluence::RequestBuilder::VERSION = '1.02'; |
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
|
|
|
|
|
15368
|
|
|
2
|
|
|
|
|
41
|
|
10
|
2
|
|
|
2
|
|
536
|
use JSON; |
|
2
|
|
|
|
|
7589
|
|
|
2
|
|
|
|
|
34
|
|
11
|
2
|
|
|
2
|
|
587
|
use Log::Any; |
|
2
|
|
|
|
|
5133
|
|
|
2
|
|
|
|
|
6
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $logger = Log::Any->get_logger(); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
2
|
|
|
2
|
1
|
9746
|
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
|
6678
|
my ( $self, %options ) = @_; |
38
|
|
|
|
|
|
|
|
39
|
5
|
|
|
|
|
6
|
my $id = delete( $options{id} ); |
40
|
5
|
100
|
|
|
|
22
|
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
|
|
4
|
my ( $self, $base_url ) = @_; |
58
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
10
|
$self->{base_url} = $base_url; |
60
|
|
|
|
|
|
|
|
61
|
2
|
|
|
|
|
8
|
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
|
|
6
|
my ( $self, $path, %query_params ) = @_; |
77
|
|
|
|
|
|
|
|
78
|
5
|
|
|
|
|
9
|
my $url = "$self->{base_url}$path"; |
79
|
5
|
100
|
|
|
|
11
|
if (%query_params) { |
80
|
3
|
|
|
|
|
12
|
require URI::Escape; |
81
|
3
|
|
|
|
|
3
|
my @query_string = (); |
82
|
3
|
|
|
|
|
10
|
foreach my $key ( sort( keys(%query_params) ) ) { |
83
|
6
|
100
|
|
|
|
60
|
push( @query_string, ( @query_string ? '&' : '?' ) ); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
push( |
86
|
|
|
|
|
|
|
@query_string, |
87
|
|
|
|
|
|
|
join( |
88
|
|
|
|
|
|
|
'&', |
89
|
6
|
|
|
|
|
9
|
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
|
|
|
|
12
|
: ( $query_params{$key} ) |
93
|
|
|
|
|
|
|
) |
94
|
|
|
|
|
|
|
) |
95
|
|
|
|
|
|
|
); |
96
|
|
|
|
|
|
|
} |
97
|
3
|
50
|
|
|
|
66
|
$url .= ( @query_string ? join( '', @query_string ) : '' ); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
5
|
|
|
|
|
23
|
return $url; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |