The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Confluence::REST - Thin wrapper around Confluence's REST API

VERSION

version 0.01

SYNOPSIS

    use Confluence::REST;
    use Data::Dumper;

    my $confluence = Confluence::REST->new('https://confluence.example.net');

    # Set up an iterator
    $confluence->set_search_iterator(
        {
            cql    => 'type = "page" and space = "home"',
            expand => 'metadata.labels',
        }
    );

    # Keep bumping the iterator for the next page of results
    while ( my $result = $confluence->next_result ) {

        # Print the hashref representing the JSON response
        print Dumper $result;
    }

DESCRIPTION

Confluence::REST - Thin wrapper around Confluence's REST API

Confluence is a proprietary wiki from Atlassian.

This module is a thin wrapper around Confluence's REST API, which is superseding its old SOAP API. (If you want to interact with the SOAP API, there's another Perl module called Confluence::Client::XMLRPC.

This code is basically JIRA::REST with some tweaks to get it to work with the Confluence REST API.

Copyright (c) 2013 by CPqD (http://www.cpqd.com.br/).

Copyright (c) 2016 (Changes to adapt to Confluence REST APIs) by Rich Loveland.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

METHODS

new(URL, USERNAME, PASSWORD [, REST_CLIENT_CONFIG])

The constructor needs up to four arguments:

The URL is a string or a URI object denoting the base URL of the Confluence server. This is a required argument.

You may choose a specific API version by appending the /rest/api/VERSION string to the URL's path. It's more common to leave it unspecified, in which case the /rest/api/latest string is appended automatically to the URL.

The USERNAME of a Confluence user can be undefined if PASSWORD is also undefined. In such a case the user credentials are looked up in the .netrc file.

The HTTP PASSWORD of the user can be undefined, in which case the user credentials are looked up in the .netrc file. (This is the password the user uses to log in to Confluence's web interface.)

The REST_CLIENT_CONFIG is a REST::Client object used to make the REST invocations. This optional argument must be a hashref that can be fed to the REST::Client constructor. Note that the URL argument overwrites any value associated with the host key in this hash.

To use a network proxy please set the 'proxy' argument to the string or URI object describing the fully qualified (including port) URL to your network proxy. This is an extension to the REST::Client configuration and will be removed from the hash before passing it on to the REST::Client constructor.

GET(PATH [, QUERY])

Thin wrapper around the underlying REST::Client method.

Takes a required PATH and an optional QUERY string as arguments.

DELETE(PATH [, QUERY])

Thin wrapper around the underlying REST::Client method.

Takes a required PATH and an optional QUERY string as arguments.

PUT(PATH, [QUERY], VALUE, [HEADERS])

Thin wrapper around the underlying REST::Client method.

Takes as arguments: a required PATH, an optional QUERY string, an required hashref VALUE which is encoded as JSON, and an optional hashref of HEADERS.

POST(PATH, [QUERY], VALUE, [HEADERS])

Thin wrapper around the underlying REST::Client method.

Takes as arguments: a required PATH, an optional QUERY string, a required hashref VALUE which is encoded as JSON, and an optional hashref of HEADERS.

set_search_iterator(PARAMS)

Used to create an "iterator" against which you will later "kick" for results (in HOP parlance), using the next_result method. PARAMS must conform to the query parameters supported by the Confluence API.

    $confluence->set_search_iterator(
        {
            cql    => 'label = test and type = page',
            expand => 'metadata.labels',
        }
    );
next_result()

Call this method to get the next page of results from your Confluence API call. Requires that you have already called set_search_iterator.

    while ( my $item = $confluence->next_result ) {
        # ... do things with the result
    }

SEE ALSO

  • REST::Client

    Confluence::REST uses a REST::Client object to perform the low-level interactions.

  • JIRA::REST

    This code is basically JIRA::REST with some tweaks to get it to work with the Confluence REST API.

REPOSITORY

https://github.com/rmloveland/Confluence-REST

AUTHOR

Richard M. Loveland <r@rmloveland.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by CPqD <www.cpqd.com.br>.

Changes to adapt to Confluence REST APIs copyright (c) 2016, 2017 by Richard Loveland.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.