line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bintray::API::Package; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
####################### |
4
|
|
|
|
|
|
|
# LOAD CORE MODULES |
5
|
|
|
|
|
|
|
####################### |
6
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
7
|
1
|
|
|
1
|
|
3
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
8
|
1
|
|
|
1
|
|
4
|
use Carp qw(croak carp); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
50
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
####################### |
11
|
|
|
|
|
|
|
# VERSION |
12
|
|
|
|
|
|
|
####################### |
13
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
####################### |
16
|
|
|
|
|
|
|
# LOAD CPAN MODULES |
17
|
|
|
|
|
|
|
####################### |
18
|
1
|
|
|
1
|
|
3
|
use Params::Validate qw(validate_with :types); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
133
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
4
|
use Object::Tiny qw( |
21
|
|
|
|
|
|
|
name |
22
|
|
|
|
|
|
|
repo |
23
|
|
|
|
|
|
|
session |
24
|
1
|
|
|
1
|
|
4
|
); |
|
1
|
|
|
|
|
1
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
####################### |
27
|
|
|
|
|
|
|
# LOAD DIST MODULES |
28
|
|
|
|
|
|
|
####################### |
29
|
1
|
|
|
1
|
|
182
|
use Bintray::API::Session; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
30
|
1
|
|
|
1
|
|
338
|
use Bintray::API::Version; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
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
|
|
|
|
|
|
|
repo => { |
51
|
|
|
|
|
|
|
type => OBJECT, |
52
|
|
|
|
|
|
|
isa => 'Bintray::API::Repo', |
53
|
|
|
|
|
|
|
}, |
54
|
|
|
|
|
|
|
}, |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
return $class->SUPER::new(%opts); |
58
|
|
|
|
|
|
|
} ## end sub new |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
## Version Object |
61
|
|
|
|
|
|
|
sub version { |
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::Version->new( |
74
|
|
|
|
|
|
|
session => $self->session(), |
75
|
|
|
|
|
|
|
package => $self, |
76
|
|
|
|
|
|
|
name => $opts{name}, |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
} ## end sub version |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
####################### |
81
|
|
|
|
|
|
|
# API METHODS |
82
|
|
|
|
|
|
|
####################### |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
## Package Info |
85
|
|
|
|
|
|
|
sub info { |
86
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
87
|
0
|
|
|
|
|
|
return $self->session()->talk( |
88
|
|
|
|
|
|
|
path => join( '/', |
89
|
|
|
|
|
|
|
'packages', $self->repo()->subject()->name(), |
90
|
|
|
|
|
|
|
$self->repo()->name(), $self->name(), |
91
|
|
|
|
|
|
|
), |
92
|
|
|
|
|
|
|
anon => 1, |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
} ## end sub info |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
## Update Package |
97
|
|
|
|
|
|
|
sub update { |
98
|
0
|
|
|
0
|
0
|
|
my ( $self, @args ) = @_; |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
my %opts = validate_with( |
101
|
|
|
|
|
|
|
params => [@args], |
102
|
|
|
|
|
|
|
spec => { |
103
|
|
|
|
|
|
|
details => { |
104
|
|
|
|
|
|
|
type => HASHREF, |
105
|
|
|
|
|
|
|
}, |
106
|
|
|
|
|
|
|
}, |
107
|
|
|
|
|
|
|
); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# Create JSON |
110
|
0
|
|
|
|
|
|
my $json = $self->session()->json()->encode( $opts{details} ); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# POST |
113
|
0
|
|
|
|
|
|
return $self->session()->talk( |
114
|
|
|
|
|
|
|
method => 'PATCH', |
115
|
|
|
|
|
|
|
path => join( '/', |
116
|
|
|
|
|
|
|
'packages', $self->repo()->subject()->name(), |
117
|
|
|
|
|
|
|
$self->repo()->name(), $self->name(), |
118
|
|
|
|
|
|
|
), |
119
|
|
|
|
|
|
|
content => $json, |
120
|
|
|
|
|
|
|
); |
121
|
|
|
|
|
|
|
} ## end sub update |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
## Create Version |
124
|
|
|
|
|
|
|
sub create_version { |
125
|
0
|
|
|
0
|
0
|
|
my ( $self, @args ) = @_; |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
my %opts = validate_with( |
128
|
|
|
|
|
|
|
params => [@args], |
129
|
|
|
|
|
|
|
spec => { |
130
|
|
|
|
|
|
|
details => { |
131
|
|
|
|
|
|
|
type => HASHREF, |
132
|
|
|
|
|
|
|
}, |
133
|
|
|
|
|
|
|
}, |
134
|
|
|
|
|
|
|
); |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# Create JSON |
137
|
0
|
|
|
|
|
|
my $json = $self->session()->json()->encode( $opts{details} ); |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# POST |
140
|
0
|
|
|
|
|
|
return $self->session()->talk( |
141
|
|
|
|
|
|
|
method => 'POST', |
142
|
|
|
|
|
|
|
path => join( '/', |
143
|
|
|
|
|
|
|
'packages', $self->repo()->subject()->name(), |
144
|
|
|
|
|
|
|
$self->repo()->name(), $self->name(), |
145
|
|
|
|
|
|
|
'versions', ), |
146
|
|
|
|
|
|
|
content => $json, |
147
|
|
|
|
|
|
|
); |
148
|
|
|
|
|
|
|
} ## end sub create_version |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
## Delete version |
151
|
|
|
|
|
|
|
sub delete_version { |
152
|
0
|
|
|
0
|
0
|
|
my ( $self, @args ) = @_; |
153
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
my %opts = validate_with( |
155
|
|
|
|
|
|
|
params => [@args], |
156
|
|
|
|
|
|
|
spec => { |
157
|
|
|
|
|
|
|
name => { |
158
|
|
|
|
|
|
|
type => SCALAR, |
159
|
|
|
|
|
|
|
}, |
160
|
|
|
|
|
|
|
}, |
161
|
|
|
|
|
|
|
); |
162
|
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
|
return $self->session()->talk( |
164
|
|
|
|
|
|
|
method => 'DELETE', |
165
|
|
|
|
|
|
|
path => join( '/', |
166
|
|
|
|
|
|
|
'packages', $self->repo()->subject()->name(), |
167
|
|
|
|
|
|
|
$self->repo()->name(), $self->name(), |
168
|
|
|
|
|
|
|
'versions', $opts{name}, |
169
|
|
|
|
|
|
|
), |
170
|
|
|
|
|
|
|
); |
171
|
|
|
|
|
|
|
} ## end sub delete_version |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
## Get Attributes |
174
|
|
|
|
|
|
|
sub get_attributes { |
175
|
0
|
|
|
0
|
0
|
|
my ( $self, @args ) = @_; |
176
|
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
my %opts = validate_with( |
178
|
|
|
|
|
|
|
params => [@args], |
179
|
|
|
|
|
|
|
spec => { |
180
|
|
|
|
|
|
|
names => { |
181
|
|
|
|
|
|
|
type => ARRAYREF, |
182
|
|
|
|
|
|
|
default => [], |
183
|
|
|
|
|
|
|
}, |
184
|
|
|
|
|
|
|
}, |
185
|
|
|
|
|
|
|
); |
186
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
return $self->session->talk( |
188
|
|
|
|
|
|
|
path => join( '/', |
189
|
|
|
|
|
|
|
'packages', $self->repo()->subject()->name(), |
190
|
|
|
|
|
|
|
$self->repo()->name(), $self->name(), |
191
|
|
|
|
|
|
|
'attributes', ), ( |
192
|
|
|
|
|
|
|
defined $opts{names} |
193
|
|
|
|
|
|
|
? ( |
194
|
|
|
|
|
|
|
query => [ |
195
|
|
|
|
|
|
|
{ |
196
|
0
|
0
|
|
|
|
|
names => join( ',', @{ $opts{names} } ), |
197
|
|
|
|
|
|
|
}, |
198
|
|
|
|
|
|
|
], |
199
|
|
|
|
|
|
|
) |
200
|
|
|
|
|
|
|
: (), |
201
|
|
|
|
|
|
|
), |
202
|
|
|
|
|
|
|
); |
203
|
|
|
|
|
|
|
} ## end sub get_attributes |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
# Set Attributes |
206
|
|
|
|
|
|
|
sub set_attributes { |
207
|
0
|
|
|
0
|
0
|
|
my ( $self, @args ) = @_; |
208
|
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
|
my %opts = validate_with( |
210
|
|
|
|
|
|
|
params => [@args], |
211
|
|
|
|
|
|
|
spec => { |
212
|
|
|
|
|
|
|
attributes => { |
213
|
|
|
|
|
|
|
type => ARRAYREF, |
214
|
|
|
|
|
|
|
}, |
215
|
|
|
|
|
|
|
update => { |
216
|
|
|
|
|
|
|
type => BOOLEAN, |
217
|
|
|
|
|
|
|
default => 0, |
218
|
|
|
|
|
|
|
}, |
219
|
|
|
|
|
|
|
}, |
220
|
|
|
|
|
|
|
); |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
# Create JSON |
223
|
0
|
|
|
|
|
|
my $json = $self->session()->json()->encode( $opts{attributes} ); |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
# POST |
226
|
0
|
0
|
|
|
|
|
return $self->session()->talk( |
227
|
|
|
|
|
|
|
method => $opts{update} ? 'PATCH' : 'POST', |
228
|
|
|
|
|
|
|
path => join( '/', |
229
|
|
|
|
|
|
|
'packages', $self->repo()->subject()->name(), |
230
|
|
|
|
|
|
|
$self->repo()->name(), $self->name(), |
231
|
|
|
|
|
|
|
'attributes', ), |
232
|
|
|
|
|
|
|
content => $json, |
233
|
|
|
|
|
|
|
); |
234
|
|
|
|
|
|
|
} ## end sub set_attributes |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
## Update Attributes |
237
|
0
|
|
|
0
|
0
|
|
sub update_attributes { return shift->set_attributes( @_, update => 1, ); } |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
## Add WebHook |
240
|
|
|
|
|
|
|
sub set_webhook { |
241
|
0
|
|
|
0
|
0
|
|
my ( $self, @args ) = @_; |
242
|
|
|
|
|
|
|
|
243
|
0
|
|
|
|
|
|
my %opts = validate_with( |
244
|
|
|
|
|
|
|
params => [@args], |
245
|
|
|
|
|
|
|
spec => { |
246
|
|
|
|
|
|
|
url => { type => SCALAR }, |
247
|
|
|
|
|
|
|
method => { |
248
|
|
|
|
|
|
|
type => SCALAR, |
249
|
|
|
|
|
|
|
default => 'post', |
250
|
|
|
|
|
|
|
regex => qr{^(?:post|put|get)$}xi, |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
}, |
253
|
|
|
|
|
|
|
); |
254
|
|
|
|
|
|
|
|
255
|
0
|
|
|
|
|
|
return $self->session->talk( |
256
|
|
|
|
|
|
|
method => 'POST', |
257
|
|
|
|
|
|
|
path => join( '/', |
258
|
|
|
|
|
|
|
'webhooks', $self->repo()->subject()->name(), |
259
|
|
|
|
|
|
|
$self->repo()->name(), $self->name(), |
260
|
|
|
|
|
|
|
), |
261
|
|
|
|
|
|
|
wantheaders => 1, |
262
|
|
|
|
|
|
|
); |
263
|
|
|
|
|
|
|
} ## end sub set_webhook |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
## Delete webhook |
266
|
|
|
|
|
|
|
sub delete_webhook { |
267
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
268
|
0
|
|
|
|
|
|
return $self->session->talk( |
269
|
|
|
|
|
|
|
method => 'DELETE', |
270
|
|
|
|
|
|
|
path => join( '/', |
271
|
|
|
|
|
|
|
'webhooks', $self->repo()->subject()->name(), |
272
|
|
|
|
|
|
|
$self->repo()->name(), $self->name(), |
273
|
|
|
|
|
|
|
), |
274
|
|
|
|
|
|
|
); |
275
|
|
|
|
|
|
|
} ## end sub delete_webhook |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
####################### |
278
|
|
|
|
|
|
|
1; |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
__END__ |