Socialtext::Resting - module for accessing Socialtext REST APIs
use Socialtext::Resting; my $Rester = Socialtext::Resting->new( username => $opts{username}, password => $opts{password}, server => $opts{server}, ); $Rester->workspace('wikiname'); $Rester->get_page('my_page'); }
Socialtext::Resting is a module designed to allow remote access to the Socialtext REST APIs for use in perl programs.
Socialtext::Resting
my $Rester = Socialtext::Resting->new( username => $opts{username}, password => $opts{password}, server => $opts{server}, ); or my $Rester = Socialtext::Resting->new( user_cookie => $opts{user_cookie}, server => $opts{server}, );
Creates a Socialtext::Resting object for the specified server/user/password, or server/cookie combination.
$Rester->accept($mime_type);
Sets the HTTP Accept header to ask the server for a specific representation in future requests.
Standard representations: http://www.socialtext.net/st-rest-docs/index.cgi?standard_representations
Common representations:
$Rester->workspace('wikiname'); $Rester->get_page('page_name');
Retrieves the content of the specified page. Note that the workspace method needs to be called first to specify which workspace to operate on.
$Rester->workspace('wikiname'); $Rester->get_page_revision('page_name', 'revision_id');
Retrieves the content of the specified page revision. Note that the workspace method needs to be called first to specify which workspace to operate on.
$Rester->workspace('wikiname'); $Rester->get_attachment('attachment_id');
Retrieves the specified attachment from the workspace. Note that the workspace method needs to be called first to specify which workspace to operate on.
$Rester->workspace('wikiname'); $Rester->put_workspacetag('tag');
Add the specified tag to the workspace.
$Rester->workspace('wikiname'); $Rester->put_pagetag('page_name', 'tag');
Add the specified tag to the page.
$Rester->workspace('wikiname'); $Rester->delete_workspacetag('tag');
Delete the specified tag from the workspace.
$Rester->workspace('wikiname'); $Rester->delete_pagetag('page_name', 'tag');
Delete the specified tag from the page.
$Rester->workspace('wikiname'); $Rester->post_attachment('page_name',$id,$content,$mime_type);
Attach the file to the specified page
$Rester->workspace('wikiname'); $Rester->post_comment( 'page_name', "me too" );
Add a comment to a page.
$Rester->workspace('wikiname'); $Rester->put_page('page_name',$content);
Save the content as a page in the wiki. $content can either be a string, which is treated as wikitext, or a hash with the following keys:
A string which is the page's wiki content.
RFC 2616 HTTP Date format string of the time the page was last edited
A username of the last editor of the page. If the the user does not exist it will be created, but will not be added to the workspace.
$Rester->workspace('wikiname'); $Rester->delete_page('page_name');
Delete the specified page.
my $id = $Rester->name_to_id($name); my $id = Socialtext::Resting::name_to_id($name);
Convert a page name into a page ID. Can be called as a method or as a function.
$Rester->workspace('wikiname'); $Rester->get_pages();
List all pages in the wiki.
$Rester->get_page_attachments($page)
List all the attachments on a page.
$Rester->get_sheet_cell($page_id, $cellid)
Get the value of a cell in a spreadsheet.
$Rester->get_revisions($page)
List all the revisions of a page.
$Rester->workspace('wikiname'); $Rester->get_taghistory($page)
Get a history, by revision, of all tags for a page.
$Rester->workspace('foo'); $Rester->get_workspace_tags()
List all the tags in workspace foo.
Return the page name of the homepage of the current workspace.
$Rester->workspace('wikiname'); $Rester->get_backlinks('page_name');
List all backlinks to the specified page
$Rester->workspace('wikiname'); $Rester->get_frontlinks('page_name');
List all 'frontlinks' on the specified page
$Rester->workspace('wikiname'); $Rester->get_pagetags('page_name');
List all pagetags on the specified page
$Rester->worksapce('wikiname'); $Rester->get_taggedpages('tag');
List all the pages that are tagged with 'tag'.
$Rester->workspace('wikiname'); $Rester->get_tag('tag');
Retrieves the specified tag from the workspace. Note that the workspace method needs to be called first to specify which workspace to operate on.
$Rester->get_breadcrumbs('workspace')
Get breadcrumbs for current user in this workspace
$Rester->get_workspace();
Return the metadata about a particular workspace.
$Rester->get_workspaces();
List all workspaces on the server
my $userinfo = $Rester->get_user($username); print $userinfo->{email_address};
Get information about a username
$Rester->create_user( { username => $username, email_address => $email, password => $password } );
Create a new user. Other parameters can be specified, see POD for Socialtext::User. username is optional and will default to the email address, as in most cases username and email_address will be the same.
$Rester->add_user_to_workspace( $workspace, { username => $user, rolename => $role, send_confirmation_invitation => 0 || 1, from_address => $from_email } );
Add a user that already exists to a workspace. rolename defaults to 'member', send_confirmation_invitation defaults to '0'. from_address must refer to a valid existing user, and is only needed if send_confirmation_invitation is set to '1'. If the user is already a member of the workspace, this will reset their role if you specify a role that's different from their current role.
my @users = $Rester->get_users_for_workspace( $workspace ); for ( @users ) { print "$_->{name}, $_->{role}, $->{is_workspace_admin}\n" }
Get a list of users in a workspace, and their roles and admin status.
$Rester->put_persontag( $person, $tag )
Tag a person.
$Rester->get_persontags($person);
Retrieves all tags for a person
$Rester->get_people();
Retrieves all people.
$Rester->get_person();
Retrieves a person.
$Rester->get_signals(); $Rester->get_signals(group_id => 42); $Rester->get_signals(account_id => 2);
Retrieves the list of signals.
Optional arguments are passed as query paramaters.
$Rester->post_signal('O HAI'); $Rester->post_signal('O HAI', group_id => 42); $Rester->post_signal('O HAI', group_ids => [2,3,4]); $Rester->post_signal('O HAI', account_id => 42); $Rester->post_signal('O HAI', account_ids => [2,3,4]); $Rester->post_signal('O HAI', in_reply_to => { signal_id => 142 });
Posts a signal.
Optional account_ids and group_ids arguments for targetting the signal.
account_ids
group_ids
Optional in_reply_to_id for specifying a signal_id this signal is in reply to.
in_reply_to_id
Optional annotations to annotate the signal. annotations should be an array ref containing hashrefs that have one key (the annotation type) and a value that is a hashref containing key/value pairs.
annotations
$Rester->post_webhook( %args )
Creates a webhook. Args will be encoded as JSON and put up.
my $hooks = $Rester->get_webhooks();
Returns an arrayref containing hashrefs of each webhook on the server.
$Rester->delete_webhook( id => $webhook_id );
Deletes the specified webhook.
my $resp = $Rester->response;
Return the HTTP::Response object from the last request.
Shawn Devlin <shawn.devlin@socialtext.com>
<shawn.devlin@socialtext.com>
Kevin Jones <kevin.jones@socialtext.com>
<kevin.jones@socialtext.com>
Brandon Noard <brandon.noard@socialtext.com>
<brandon.noard@socialtext.com>
Luke Closs
Jeremy Stashewsky
Chris Dent
Kirsten Jones
Michele Berg - get_revisions()
To install Socialtext::Resting, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Socialtext::Resting
CPAN shell
perl -MCPAN -e shell install Socialtext::Resting
For more information on module installation, please visit the detailed CPAN module installation guide.