line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JIRA::Client::REST; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$JIRA::Client::REST::VERSION = '0.06'; |
4
|
|
|
|
|
|
|
} |
5
|
3
|
|
|
3
|
|
219731
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: JIRA REST Client |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use JSON qw(decode_json encode_json); |
10
|
|
|
|
|
|
|
use Net::HTTP::Spore; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has '_client' => ( |
14
|
|
|
|
|
|
|
is => 'rw', |
15
|
|
|
|
|
|
|
lazy => 1, |
16
|
|
|
|
|
|
|
default => sub { |
17
|
|
|
|
|
|
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $client = Net::HTTP::Spore->new_from_string( |
20
|
|
|
|
|
|
|
'{ |
21
|
|
|
|
|
|
|
"name": "JIRA", |
22
|
|
|
|
|
|
|
"authority": "GITHUB:gphat", |
23
|
|
|
|
|
|
|
"version": "1.0", |
24
|
|
|
|
|
|
|
"methods": { |
25
|
|
|
|
|
|
|
"get_issue": { |
26
|
|
|
|
|
|
|
"path": "/rest/api/latest/issue/:id", |
27
|
|
|
|
|
|
|
"required_params": [ |
28
|
|
|
|
|
|
|
"id" |
29
|
|
|
|
|
|
|
], |
30
|
|
|
|
|
|
|
"optional_params": [ |
31
|
|
|
|
|
|
|
"expand" |
32
|
|
|
|
|
|
|
], |
33
|
|
|
|
|
|
|
"method": "GET", |
34
|
|
|
|
|
|
|
"authentication": true |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
"get_issue_transitions": { |
37
|
|
|
|
|
|
|
"path": "/rest/api/latest/issue/:id/transitions", |
38
|
|
|
|
|
|
|
"required_params": [ |
39
|
|
|
|
|
|
|
"id" |
40
|
|
|
|
|
|
|
], |
41
|
|
|
|
|
|
|
"optional_params": [ |
42
|
|
|
|
|
|
|
"expand" |
43
|
|
|
|
|
|
|
], |
44
|
|
|
|
|
|
|
"method": "GET", |
45
|
|
|
|
|
|
|
"authentication": true |
46
|
|
|
|
|
|
|
}, |
47
|
|
|
|
|
|
|
"get_issue_votes": { |
48
|
|
|
|
|
|
|
"path": "/rest/api/latest/issue/:id/votes", |
49
|
|
|
|
|
|
|
"required_params": [ |
50
|
|
|
|
|
|
|
"id" |
51
|
|
|
|
|
|
|
], |
52
|
|
|
|
|
|
|
"optional_params": [ |
53
|
|
|
|
|
|
|
"expand" |
54
|
|
|
|
|
|
|
], |
55
|
|
|
|
|
|
|
"method": "GET", |
56
|
|
|
|
|
|
|
"authentication": true |
57
|
|
|
|
|
|
|
}, |
58
|
|
|
|
|
|
|
"get_issue_watchers": { |
59
|
|
|
|
|
|
|
"path": "/rest/api/latest/issue/:id/watchers", |
60
|
|
|
|
|
|
|
"required_params": [ |
61
|
|
|
|
|
|
|
"id" |
62
|
|
|
|
|
|
|
], |
63
|
|
|
|
|
|
|
"optional_params": [ |
64
|
|
|
|
|
|
|
"expand" |
65
|
|
|
|
|
|
|
], |
66
|
|
|
|
|
|
|
"method": "GET", |
67
|
|
|
|
|
|
|
"authentication": true |
68
|
|
|
|
|
|
|
}, |
69
|
|
|
|
|
|
|
"get_project": { |
70
|
|
|
|
|
|
|
"path": "/rest/api/latest/project/:key", |
71
|
|
|
|
|
|
|
"required_params": [ |
72
|
|
|
|
|
|
|
"key" |
73
|
|
|
|
|
|
|
], |
74
|
|
|
|
|
|
|
"method": "GET", |
75
|
|
|
|
|
|
|
"authentication": true |
76
|
|
|
|
|
|
|
}, |
77
|
|
|
|
|
|
|
"get_project_versions": { |
78
|
|
|
|
|
|
|
"path": "/rest/api/latest/project/:key/versions", |
79
|
|
|
|
|
|
|
"required_params": [ |
80
|
|
|
|
|
|
|
"key" |
81
|
|
|
|
|
|
|
], |
82
|
|
|
|
|
|
|
"method": "GET", |
83
|
|
|
|
|
|
|
"authentication": true |
84
|
|
|
|
|
|
|
}, |
85
|
|
|
|
|
|
|
"get_version": { |
86
|
|
|
|
|
|
|
"path": "/rest/api/latest/version/:id", |
87
|
|
|
|
|
|
|
"required_params": [ |
88
|
|
|
|
|
|
|
"id" |
89
|
|
|
|
|
|
|
], |
90
|
|
|
|
|
|
|
"method": "GET", |
91
|
|
|
|
|
|
|
"authentication": true |
92
|
|
|
|
|
|
|
}, |
93
|
|
|
|
|
|
|
"unvote_for_issue": { |
94
|
|
|
|
|
|
|
"path": "/rest/api/latest/issue/:id/votes", |
95
|
|
|
|
|
|
|
"required_params": [ |
96
|
|
|
|
|
|
|
"id" |
97
|
|
|
|
|
|
|
], |
98
|
|
|
|
|
|
|
"method": "DELETE", |
99
|
|
|
|
|
|
|
"authentication": true |
100
|
|
|
|
|
|
|
}, |
101
|
|
|
|
|
|
|
"unwatch_issue": { |
102
|
|
|
|
|
|
|
"path": "/rest/api/latest/issue/:id/watchers", |
103
|
|
|
|
|
|
|
"required_params": [ |
104
|
|
|
|
|
|
|
"id", |
105
|
|
|
|
|
|
|
"username" |
106
|
|
|
|
|
|
|
], |
107
|
|
|
|
|
|
|
"method": "DELETE", |
108
|
|
|
|
|
|
|
"authentication": true |
109
|
|
|
|
|
|
|
}, |
110
|
|
|
|
|
|
|
"vote_for_issue": { |
111
|
|
|
|
|
|
|
"path": "/rest/api/latest/issue/:id/votes", |
112
|
|
|
|
|
|
|
"required_params": [ |
113
|
|
|
|
|
|
|
"id" |
114
|
|
|
|
|
|
|
], |
115
|
|
|
|
|
|
|
"method": "POST", |
116
|
|
|
|
|
|
|
"authentication": true |
117
|
|
|
|
|
|
|
}, |
118
|
|
|
|
|
|
|
"watch_issue": { |
119
|
|
|
|
|
|
|
"path": "/rest/api/latest/issue/:id/watchers", |
120
|
|
|
|
|
|
|
"required_params": [ |
121
|
|
|
|
|
|
|
"id", |
122
|
|
|
|
|
|
|
"username" |
123
|
|
|
|
|
|
|
], |
124
|
|
|
|
|
|
|
"method": "POST", |
125
|
|
|
|
|
|
|
"authentication": true |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
}', |
129
|
|
|
|
|
|
|
base_url => $self->url, |
130
|
|
|
|
|
|
|
trace => $self->debug, |
131
|
|
|
|
|
|
|
); |
132
|
|
|
|
|
|
|
$client->enable('Format::JSON'); |
133
|
|
|
|
|
|
|
$client->enable('Auth::Basic', username => $self->username, password => $self->password); |
134
|
|
|
|
|
|
|
return $client; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
); |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
has 'debug' => ( |
139
|
|
|
|
|
|
|
is => 'rw', |
140
|
|
|
|
|
|
|
isa => 'Bool', |
141
|
|
|
|
|
|
|
default => 0, |
142
|
|
|
|
|
|
|
); |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
has 'password' => ( |
146
|
|
|
|
|
|
|
is => 'rw', |
147
|
|
|
|
|
|
|
isa => 'Str', |
148
|
|
|
|
|
|
|
required => 1 |
149
|
|
|
|
|
|
|
); |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
has 'url' => ( |
153
|
|
|
|
|
|
|
is => 'rw', |
154
|
|
|
|
|
|
|
isa => 'Str', |
155
|
|
|
|
|
|
|
required => 1 |
156
|
|
|
|
|
|
|
); |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
has 'username' => ( |
160
|
|
|
|
|
|
|
is => 'rw', |
161
|
|
|
|
|
|
|
isa => 'Str', |
162
|
|
|
|
|
|
|
required => 1 |
163
|
|
|
|
|
|
|
); |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub get_issue { |
167
|
|
|
|
|
|
|
my ($self, $id, $expand) = @_; |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
return $self->_client->get_issue(id => $id, expand => $expand); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub get_issue_transitions { |
174
|
|
|
|
|
|
|
my ($self, $id, $expand) = @_; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
return $self->_client->get_issue_transitions(id => $id, expand => $expand); |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub get_issue_votes { |
181
|
|
|
|
|
|
|
my ($self, $id, $expand) = @_; |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
return $self->_client->get_issue_votes(id => $id, expand => $expand); |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub get_issue_watchers { |
188
|
|
|
|
|
|
|
my ($self, $id, $expand) = @_; |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
return $self->_client->get_issue_watchers(id => $id, expand => $expand); |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
sub get_project { |
195
|
|
|
|
|
|
|
my ($self, $key) = @_; |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
return $self->_client->get_project(key => $key); |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
sub get_project_versions { |
202
|
|
|
|
|
|
|
my ($self, $key) = @_; |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
return $self->_client->get_project_versions(key => $key); |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub get_version { |
209
|
|
|
|
|
|
|
my ($self, $id) = @_; |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
return $self->_client->get_version(id => $id); |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub unvote_for_issue { |
216
|
|
|
|
|
|
|
my ($self, $id) = @_; |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
return $self->_client->unvote_for_issue(id => $id); |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub unwatch_issue { |
223
|
|
|
|
|
|
|
my ($self, $id, $username) = @_; |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
return $self->_client->unwatch_issue(id => $id, username => $username); |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
sub vote_for_issue { |
230
|
|
|
|
|
|
|
my ($self, $id) = @_; |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
return $self->_client->vote_for_issue(id => $id); |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
sub watch_issue { |
237
|
|
|
|
|
|
|
my ($self, $id, $username) = @_; |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
return $self->_client->watch_issue(id => $id, username => $username); |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
1; |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
__END__ |
245
|
|
|
|
|
|
|
=pod |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head1 NAME |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
JIRA::Client::REST - JIRA REST Client |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head1 VERSION |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
version 0.06 |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head1 SYNOPSIS |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
use JIRA::Client::REST; |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
my $client = JIRA::Client::REST->new( |
260
|
|
|
|
|
|
|
username => 'username', |
261
|
|
|
|
|
|
|
password => 'password', |
262
|
|
|
|
|
|
|
url => 'http://jira.mycompany.com', |
263
|
|
|
|
|
|
|
); |
264
|
|
|
|
|
|
|
my $issue = $client->get_issue('TICKET-12'); |
265
|
|
|
|
|
|
|
print $issue->{fields}->{priority}->{value}->{name}."\n"; |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=head1 DESCRIPTION |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
JIRA::Client::REST is a wrapper for the L<JIRA REST API|http://docs.atlassian.com/jira/REST/latest/>. |
270
|
|
|
|
|
|
|
It is a thin wrapper, returning decoded version of the JSON without any munging |
271
|
|
|
|
|
|
|
or mangling. |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=head1 HEADS UP |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
This module is under development and some of the REST API hasn't been implemented |
276
|
|
|
|
|
|
|
yet. |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=head2 password |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
Set/Get the password to use when connecting to JIRA. |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=head2 url |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
Set/Get the URL for the JIRA instance. |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=head2 username |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
Set/Get the username to use when connecting to JIRA. |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
=head1 METHODS |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=head2 get_issue($id, $expand) |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
Get the issue with the supplied id. Returns a HashRef of data. |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=head2 get_issue_transitions($id, $expand) |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
Get the transitions possible for this issue by the current user. |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
=head2 get_issue_votes($id, $expand) |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
Get voters on the issue. |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=head2 get_issue_watchers($id, $expand) |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
Get watchers on the issue. |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=head2 get_project($key) |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
Get the project for the specifed key. |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=head2 get_project_versions($key) |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
Get the versions for the project with the specified key. |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=head2 get_version($id) |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
Get the version with the specified id. |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
=head2 unvote_for_issue($id) |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
Remove your vote from an issue. |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=head2 unwatch_issue($id, $username) |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
Remove a watcher from an issue. |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
=head2 vote_for_issue($id) |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
Cast your vote in favor of an issue. |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
=head2 watch_issue($id, $username) |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
Watch an issue. (Or have someone else watch it.) |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
=head1 AUTHOR |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
Cory G Watson <gphat@cpan.org> |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Cold Hard Code, LLC. |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
347
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
=cut |
350
|
|
|
|
|
|
|
|