NAME
Confluence::Client::XMLRPC - Client for the Atlassian Confluence wiki, based on RPC::XML
VERSION
version 2.2
SYNOPSIS
my $object = Confluence::Client::XMLRPC->new( <URL>, <user>, <pass> );
my $result = $object->method(argument,..);
CAVEAT
ATTENTION, please: This module was written by Asgeir Nilsen in 2004 and later on improved by Giles Lewis, Martin Ellis, and Torben K. Jensen.
I - Heiko Jansen - only took the available source code and created a CPAN distribution for it, because at least to me a Perl module almost does not exist if it's not on available via CPAN.
This package should work with any remote API function.
The original authors tested it with addUserToGroup, getActiveUsers, getPage, getPages, getServerInfo, getUser, and storePage. I (Heiko Jansen) have used it successfully to create and update pages, but I did not test most other API functions and am thus unable to give any guarantee that it will work as expected!
The original module was simply named "Confluence" but since Atlassian is currently working on a new REST-based API and since there already is Jira::Client and Jira::Client::REST on CPAN I renamed it to Confluence::Client::XMLRPC.
ERROR HANDLING
This package has two global flags which control error handings.
Confluence::Client::XMLRPC::setRaiseError(1); # Enable die
Confluence::Client::XMLRPC::setPrintError(1); # Enable warn
Confluence::Client::XMLRPC::setRaiseError(0); # Disable die
Confluence::Client::XMLRPC::setPrintError(0); # Disable warn
The setRaiseError and setPrintError functions both return the previous setting of the flag so that it may be restored if necessary.
RaiseError is initially set to 1 to preserve the original package behavior.
PrintError is initially set to 0.
If RaiseError is set to 0 then Confluence::Client::XMLRPC::lastError() can be used to determine if an error occurred.
Confluence::Client::XMLRPC::setRaiseError(0);
my $page = $wiki->getPage($space, $title);
if ( my $e = Confluence::Client::XMLRPC::lastError() ) {
say $e;
}
USAGE
Data types
Perl simple data types are mapped to string. Hash references are mapped to struct. Array references are mapped to array.
This package now automatically converts all scalars to RPC::XML::string, so explicit type conversions should not be required.
API extension
- updatePage
-
This package has a function called
updatePagewhich is not part of the original remote API. If the page id is not specified then the function will callstorePageto do an insert. If an "already exists" error is encountered then the function will callgetPageto retrieve the page id and version, and then repeat thestorePageattempt. This function is intended to be used in situations where the intent is to upload pages, overwriting existing content if it exists. See example below.
EXAMPLES
upload_files.pl- Upload files-
The sample script uploads the contents of a directory to the wiki. Each file in the directory is uploaded as a separate page. The page title is the file name with extension removed. This script requires five arguments: API url, user name, password, space key and a directory name.
upload_users.pl- Upload Users-
This script reads and loads a list of users from a file (or stdin). If errors are encountered then the script will print an error message, but continue processing. This script requires three arguments: API url, name and password of an admin user.
det_group_mbrship.pl- Determine Group Membership-
The script prints the group membership of all users. This script requires three arguments: API url, name and password of an admin user.
Please refer to the examples directory of the distribution for the scripts themselves.
SEE ALSO
The package uses the RPC::XML module to do the heavy lifting. Read the perldoc for this package to learn more.
For further information on the Confluence API itself please refer to the official documentation as provided by Atlassian.
AUTHORS
Asgeir Nilsen
Giles Lewis
Martin Ellis
Torben K. Jensen
Heiko Jansen <hjansen@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2013 by Heiko Jansen.
This is free software, licensed under:
The GNU General Public License, Version 2, June 1991