line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bintray::API::Repo; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
####################### |
4
|
|
|
|
|
|
|
# LOAD CORE MODULES |
5
|
|
|
|
|
|
|
####################### |
6
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
7
|
1
|
|
|
1
|
|
7
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
49
|
|
8
|
1
|
|
|
1
|
|
6
|
use Carp qw(croak carp); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
111
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
####################### |
11
|
|
|
|
|
|
|
# VERSION |
12
|
|
|
|
|
|
|
####################### |
13
|
|
|
|
|
|
|
our $VERSION = '1.0.2'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
####################### |
16
|
|
|
|
|
|
|
# LOAD CPAN MODULES |
17
|
|
|
|
|
|
|
####################### |
18
|
1
|
|
|
1
|
|
7
|
use Params::Validate qw(validate_with :types); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
210
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
8
|
use Object::Tiny qw( |
21
|
|
|
|
|
|
|
name |
22
|
|
|
|
|
|
|
session |
23
|
|
|
|
|
|
|
subject |
24
|
1
|
|
|
1
|
|
8
|
); |
|
1
|
|
|
|
|
1
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
####################### |
27
|
|
|
|
|
|
|
# LOAD DIST MODULES |
28
|
|
|
|
|
|
|
####################### |
29
|
1
|
|
|
1
|
|
850
|
use Bintray::API::Package; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
15
|
|
30
|
1
|
|
|
1
|
|
42
|
use Bintray::API::Session; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
####################### |
33
|
|
|
|
|
|
|
# PUBLIC METHODS |
34
|
|
|
|
|
|
|
####################### |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
## Constructor |
37
|
|
|
|
|
|
|
sub new { |
38
|
0
|
|
|
0
|
0
|
|
my ( $class, @args ) = @_; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my %opts = validate_with( |
41
|
|
|
|
|
|
|
params => [@args], |
42
|
|
|
|
|
|
|
spec => { |
43
|
|
|
|
|
|
|
session => { |
44
|
|
|
|
|
|
|
type => OBJECT, |
45
|
|
|
|
|
|
|
isa => 'Bintray::API::Session', |
46
|
|
|
|
|
|
|
}, |
47
|
|
|
|
|
|
|
name => { |
48
|
|
|
|
|
|
|
type => SCALAR, |
49
|
|
|
|
|
|
|
}, |
50
|
|
|
|
|
|
|
subject => { |
51
|
|
|
|
|
|
|
type => OBJECT, |
52
|
|
|
|
|
|
|
isa => 'Bintray::API::Subject', |
53
|
|
|
|
|
|
|
}, |
54
|
|
|
|
|
|
|
}, |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
return $class->SUPER::new(%opts); |
58
|
|
|
|
|
|
|
} ## end sub new |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
## Package Object |
61
|
|
|
|
|
|
|
sub package { |
62
|
0
|
|
|
0
|
0
|
|
my ( $self, @args ) = @_; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
my %opts = validate_with( |
65
|
|
|
|
|
|
|
params => [@args], |
66
|
|
|
|
|
|
|
spec => { |
67
|
|
|
|
|
|
|
name => { |
68
|
|
|
|
|
|
|
type => SCALAR, |
69
|
|
|
|
|
|
|
}, |
70
|
|
|
|
|
|
|
}, |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
return Bintray::API::Package->new( |
74
|
|
|
|
|
|
|
session => $self->session(), |
75
|
|
|
|
|
|
|
repo => $self, |
76
|
|
|
|
|
|
|
name => $opts{name}, |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
} ## end sub package |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
####################### |
81
|
|
|
|
|
|
|
# API METHODS |
82
|
|
|
|
|
|
|
####################### |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
## Repo Info |
85
|
|
|
|
|
|
|
sub info { |
86
|
0
|
|
|
0
|
0
|
|
my ( $self, @args ) = @_; |
87
|
0
|
|
|
|
|
|
return $self->session()->talk( |
88
|
|
|
|
|
|
|
path => join( '/', 'repos', $self->subject()->name(), $self->name() ), |
89
|
|
|
|
|
|
|
anon => 1, |
90
|
|
|
|
|
|
|
); |
91
|
|
|
|
|
|
|
} ## end sub info |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
## Packages |
94
|
|
|
|
|
|
|
sub packages { |
95
|
0
|
|
|
0
|
0
|
|
my ( $self, @args ) = @_; |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
my %opts = validate_with( |
98
|
|
|
|
|
|
|
params => [@args], |
99
|
|
|
|
|
|
|
spec => { |
100
|
|
|
|
|
|
|
prefix => { |
101
|
|
|
|
|
|
|
type => SCALAR, |
102
|
|
|
|
|
|
|
default => '', |
103
|
|
|
|
|
|
|
}, |
104
|
|
|
|
|
|
|
}, |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
|
107
|
0
|
0
|
|
|
|
|
return $self->session()->talk( |
108
|
|
|
|
|
|
|
path => join( '/', |
109
|
|
|
|
|
|
|
'repos', $self->subject()->name(), |
110
|
|
|
|
|
|
|
$self->name(), 'packages' ), |
111
|
|
|
|
|
|
|
anon => 1, ( |
112
|
|
|
|
|
|
|
$opts{prefix} |
113
|
|
|
|
|
|
|
? ( query => [ { start_name => $opts{prefix} } ] ) |
114
|
|
|
|
|
|
|
: (), |
115
|
|
|
|
|
|
|
), |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
} ## end sub packages |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
## Create Package |
120
|
|
|
|
|
|
|
sub create_package { |
121
|
0
|
|
|
0
|
0
|
|
my ( $self, @args ) = @_; |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
my %opts = validate_with( |
124
|
|
|
|
|
|
|
params => [@args], |
125
|
|
|
|
|
|
|
spec => { |
126
|
|
|
|
|
|
|
details => { |
127
|
|
|
|
|
|
|
type => HASHREF, |
128
|
|
|
|
|
|
|
}, |
129
|
|
|
|
|
|
|
}, |
130
|
|
|
|
|
|
|
); |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# Create JSON |
133
|
0
|
|
|
|
|
|
my $json = $self->session()->json()->encode( $opts{details} ); |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# POST |
136
|
0
|
|
|
|
|
|
return $self->session()->talk( |
137
|
|
|
|
|
|
|
method => 'POST', |
138
|
|
|
|
|
|
|
path => |
139
|
|
|
|
|
|
|
join( '/', 'packages', $self->subject()->name(), $self->name(), ), |
140
|
|
|
|
|
|
|
content => $json, |
141
|
|
|
|
|
|
|
); |
142
|
|
|
|
|
|
|
} ## end sub create_package |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
## Delete Package |
145
|
|
|
|
|
|
|
sub delete_package { |
146
|
0
|
|
|
0
|
0
|
|
my ( $self, @args ) = @_; |
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
my %opts = validate_with( |
149
|
|
|
|
|
|
|
params => [@args], |
150
|
|
|
|
|
|
|
spec => { |
151
|
|
|
|
|
|
|
name => { |
152
|
|
|
|
|
|
|
type => SCALAR, |
153
|
|
|
|
|
|
|
}, |
154
|
|
|
|
|
|
|
}, |
155
|
|
|
|
|
|
|
); |
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
return $self->session()->talk( |
158
|
|
|
|
|
|
|
method => 'DELETE', |
159
|
|
|
|
|
|
|
path => join( '/', |
160
|
|
|
|
|
|
|
'packages', $self->subject()->name(), |
161
|
|
|
|
|
|
|
$self->name(), $opts{name}, |
162
|
|
|
|
|
|
|
), |
163
|
|
|
|
|
|
|
); |
164
|
|
|
|
|
|
|
} ## end sub delete_package |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
## Get Webhooks |
167
|
|
|
|
|
|
|
sub get_webhooks { |
168
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
169
|
0
|
|
|
|
|
|
return $self->session->talk( |
170
|
|
|
|
|
|
|
path => |
171
|
|
|
|
|
|
|
join( '/', 'webhooks', $self->subject()->name(), $self->name() ), |
172
|
|
|
|
|
|
|
); |
173
|
|
|
|
|
|
|
} ## end sub get_webhooks |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
####################### |
176
|
|
|
|
|
|
|
# API HELPERS |
177
|
|
|
|
|
|
|
####################### |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
## Package name |
180
|
|
|
|
|
|
|
sub package_names { |
181
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
182
|
0
|
0
|
|
|
|
|
my $resp = $self->packages() or return; |
183
|
0
|
|
|
|
|
|
my @packages = map { $_->{name} } @{$resp}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
184
|
0
|
|
|
|
|
|
return @packages; |
185
|
|
|
|
|
|
|
} ## end sub package_names |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
####################### |
188
|
|
|
|
|
|
|
1; |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
__END__ |