|
NAMEJIRA::REST - Thin wrapper around Jira's REST APIVERSIONversion 0.021SYNOPSISuse JIRA::REST; my $jira = JIRA::REST->new({ url => 'https://jira.example.net', username => 'myuser', password => 'mypass', }); # File a bug my $issue = $jira->POST('/issue', undef, { fields => { project => { key => 'PRJ' }, issuetype => { name => 'Bug' }, summary => 'Cannot login', description => 'Bla bla bla', }, }); # Get issue $issue = $jira->GET("/issue/TST-101"); # Iterate on issues my $search = $jira->POST('/search', undef, { jql => 'project = "TST" and status = "open"', startAt => 0, maxResults => 16, fields => [ qw/summary status assignee/ ], }); foreach my $issue (@{$search->{issues}}) { print "Found issue $issue->{key}\n"; } # Iterate using utility methods $jira->set_search_iterator({ jql => 'project = "TST" and status = "open"', maxResults => 16, fields => [ qw/summary status assignee/ ], }); while (my $issue = $jira->next_issue) { print "Found issue $issue->{key}\n"; } # Attach files using an utility method $jira->attach_files('TST-123', '/path/to/doc.txt', 'image.png'); DESCRIPTIONJira <http://www.atlassian.com/software/jira/> is a proprietary bug tracking system from Atlassian.This module implements a very thin wrapper around Jira's REST APIs:
CONSTRUCTORSnew HASHREFnew URL, USERNAME, PASSWORD, REST_CLIENT_CONFIG, ANONYMOUS, PROXY, SSL_VERIFY_NONEThe default constructor can take its arguments from a single hash reference or from a list of positional parameters. The first form is preferred because it lets you specify only the arguments you need. The second form forces you to pass undefined values if you need to pass a specific value to an argument further to the right.The arguments are described below with the names which must be used as the hash keys:
new_session OPTIONSThis 'session' constructor first invokes the default constructor, passing to it all the options it receives. Then it makes a "POST /rest/auth/1/session" to login to Jira, creating a user session.This is particularly useful when interacting with Jira Data Center, because it can use the session cookie to maintain affinity with one of the redundant servers. When created with this constructor, upon destruction the object makes a "DELETE /rest/auth/1/session" to logout from Jira. REST METHODSJira's REST API documentation lists dozens of "resources" which can be operated via the standard HTTP requests: GET, DELETE, PUT, and POST. JIRA::REST objects implement four methods called GET, DELETE, PUT, and POST to make it easier to invoke and get results from Jira's REST endpoints.All four methods need two arguments:
The PUT and POST methods accept two more arguments:
All four methods return the value returned by the associated resource's method, as specified in the documentation, decoded according to its content type as follows:
Some endpoints don't return anything. In those cases, the methods return "undef". The methods croak if they get any other type of values in return. In case of errors (i.e., if the underlying HTTP method return an error code different from 2xx) the methods croak with a multi-line string like this: ERROR: <CODE> - <MESSAGE> <CONTENT-TYPE> <CONTENT> So, in order to treat errors you must invoke the methods in an eval block or use any of the exception handling Perl modules, such as "Try::Tiny" and "Try::Catch". GET RESOURCE [, QUERY]Returns the RESOURCE as a Perl data structure.DELETE RESOURCE [, QUERY]Deletes the RESOURCE.PUT RESOURCE, QUERY, VALUE [, HEADERS]Creates RESOURCE based on VALUE.POST RESOURCE, QUERY, VALUE [, HEADERS]Updates RESOURCE based on VALUE.UTILITY METHODSThis module provides a few utility methods.set_search_iterator PARAMSSets up an iterator for the search specified by the hash reference PARAMS. It must be called before calls to next_issue.PARAMS must conform with the query parameters allowed for the "/rest/api/2/search" Jira REST endpoint. next_issueThis must be called after a call to set_search_iterator. Each call returns a reference to the next issue from the filter. When there are no more issues it returns undef.Using the set_search_iterator/next_issue utility methods you can iterate through large sets of issues without worrying about the startAt/total/offset attributes in the response from the /search REST endpoint. These methods implement the "paging" algorithm needed to work with those attributes. attach_files ISSUE FILE...The "/issue/KEY/attachments" REST endpoint, used to attach files to issues, requires a specific content type encoding which is difficult to come up with just the "REST::Client" interface. This utility method offers an easier interface to attach files to issues.PERL AND JIRA COMPATIBILITY POLICYCurrently JIRA::REST requires Perl 5.16 and supports Jira 7.0.We try to be compatible with the Perl native packages of the oldest Ubuntu LTS <https://www.ubuntu.com/info/release-end-of-life> and CentOS <https://wiki.centos.org/About/Product> Linux distributions still getting maintainance updates. +-------------+-----------------------+------+ | End of Life | Distro | Perl | +-------------+-----------------------+------+ | 2021-04 | Ubuntu 16.04 (xenial) | 5.22 | | 2023-04 | Ubuntu 18.04 (bionic) | 5.26 | | 2024-07 | CentOS 7 | 5.16 | | 2025-04 | Ubuntu 20.04 (focal ) | 5.30 | | 2029-05 | CentOS 8 | 5.26 | +-------------+-----------------------+------+ As you can see, we're kept behind mostly by the slow pace of CentOS (actually, RHEL) releases. As for Jira, the policy is very lax. I (the author) only test JIRA::REST on the Jira server installed in the company I work for, which is usually (but not always) at most one year older than the newest released version. I don't have yet an easy way to test it on different versions. SEE ALSO
REPOSITORY<https://github.com/gnustavo/JIRA-REST>AUTHORGustavo L. de M. Chaves <gnustavo@cpan.org>COPYRIGHT AND LICENSEThis software is copyright (c) 2021 by CPQD <www.cpqd.com.br>.This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Visit the GSP FreeBSD Man Page Interface. |