Gustavo Leite de Mendonça Chaves > JIRA-REST-0.004 > JIRA::REST

Download:
JIRA-REST-0.004.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.004   Source   Latest Release: JIRA-REST-0.006

NAME ^

JIRA::REST - A thin wrapper around JIRA's REST API

VERSION ^

version 0.004

SYNOPSIS ^

    use JIRA::REST;

    my $jira = JIRA::REST->new('https://jira.example.net', 'myuser', 'mypass');

    # Cache some JIRA objects
    my %issuetypes = map {($_->{name} => $_)} @{$jira->GET('/issuetype')};
    my %priorities = map {($_->{name} => $_)} @{$jira->GET('/priority' )};
    my %projects   = map {($_->{name} => $_)} @{$jira->GET('/project'  )};

    # A handy routine to construct id hashes
    sub id_of { return { id => $_[0]->{id} }; };

    # Cache information about a project
    my $pid        = $projects{'My Project'}->{id};
    my %components = map {($_->{name} => $_)} @{$jira->GET("/project/$pid/components")};

    # File a bug
    my $issue = $jira->POST('/issue', undef, {
        fields => {
            project   => id_of($projects{'My Project'}),
            issuetype => id_of($issuetypes{Bug}),
            summary   => 'Cannot login',
            priority  => id_of($priorities{Major}),
            versions  => [ id_of($components{auth_module}) ],
            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";
    }

DESCRIPTION ^

JIRA is a proprietary bug tracking system from Atlassian.

This module implements a very thin wrapper around JIRA's REST API which is superseding it's old SOAP API for which there is another Perl module called JIRA::Client.

CONSTRUCTOR ^

new URL, USERNAME, PASSWORD [, REST_CLIENT_CONFIG]

The constructor needs up to four arguments:

METHODS ^

JIRA'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.

SEE ALSO ^

AUTHOR ^

Gustavo L. de M. Chaves <gnustavo@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2013 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.

syntax highlighting: