r63373 - in /branches/upstream/libsocialtext-resting-perl/current: Changes MANIFEST META.yml Makefile.PL bin/st-webhook lib/Socialtext/Resting.pm
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Tue Oct 5 01:22:16 UTC 2010
Author: jawnsy-guest
Date: Tue Oct 5 01:21:57 2010
New Revision: 63373
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=63373
Log:
[svn-upgrade] new version libsocialtext-resting-perl (0.34)
Added:
branches/upstream/libsocialtext-resting-perl/current/bin/st-webhook (with props)
Modified:
branches/upstream/libsocialtext-resting-perl/current/Changes
branches/upstream/libsocialtext-resting-perl/current/MANIFEST
branches/upstream/libsocialtext-resting-perl/current/META.yml
branches/upstream/libsocialtext-resting-perl/current/Makefile.PL
branches/upstream/libsocialtext-resting-perl/current/lib/Socialtext/Resting.pm
Modified: branches/upstream/libsocialtext-resting-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsocialtext-resting-perl/current/Changes?rev=63373&op=diff
==============================================================================
--- branches/upstream/libsocialtext-resting-perl/current/Changes (original)
+++ branches/upstream/libsocialtext-resting-perl/current/Changes Tue Oct 5 01:21:57 2010
@@ -1,3 +1,18 @@
+0.34 - Fri Jul 16 09:35:49 PDT 2010
+ - Include st-webhook in the MANIFEST. Doh.
+
+0.33 - Wed Jul 14 15:14:40 PDT 2010
+ - Make sure to install st-webhook
+
+0.32 - Wed Jul 14 12:43:34 PDT 2010
+ - Use a more correct HTTP verb (POST) when creating a webhook.
+
+0.31 - Wed Jul 14 11:32:33 PDT 2010
+ - Add support for sending signals in reply to another signal.
+ - Add support for sending signals with annotations.
+ - Add "on_behalf_of" to set header for "X-On-Behalf-Of". (not docced yet)
+ - Add `st-webhook` tool to create/list/delete webhooks
+
0.30 - Thu Feb 4 10:19:42 PST 2010
- Add group and account ids to post_signal()
- Doc that get_signals() accepts query parameters (such as group & account
Modified: branches/upstream/libsocialtext-resting-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsocialtext-resting-perl/current/MANIFEST?rev=63373&op=diff
==============================================================================
--- branches/upstream/libsocialtext-resting-perl/current/MANIFEST (original)
+++ branches/upstream/libsocialtext-resting-perl/current/MANIFEST Tue Oct 5 01:21:57 2010
@@ -1,4 +1,5 @@
bin/strut
+bin/st-webhook
lib/Socialtext/Resting.pm
Makefile.PL
MANIFEST This list of files
Modified: branches/upstream/libsocialtext-resting-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsocialtext-resting-perl/current/META.yml?rev=63373&op=diff
==============================================================================
--- branches/upstream/libsocialtext-resting-perl/current/META.yml (original)
+++ branches/upstream/libsocialtext-resting-perl/current/META.yml Tue Oct 5 01:21:57 2010
@@ -1,23 +1,31 @@
--- #YAML:1.0
-name: Socialtext-Resting
-version: 0.30
-abstract: Simple tool to use Socialtext RESTful API
-license: ~
-author:
+name: Socialtext-Resting
+version: 0.34
+abstract: Simple tool to use Socialtext RESTful API
+author:
- Chris Dent <chris.dent at socialtext.com>, Kirsten Jones <kirsten.jones at socialtext.com>
-generated_by: ExtUtils::MakeMaker version 6.44
-distribution_type: module
-requires:
- App::Options: 0
- Class::Field: 0
- HTTP::Request: 0
- IPC::Run: 0
- JSON::XS: 2.1
- LWP::UserAgent: 0
- Pod::Usage: 0
- Readonly: 0
- Test::Mock::LWP: 0.05
- URI::Escape: 1.31
+license: unknown
+distribution_type: module
+configure_requires:
+ ExtUtils::MakeMaker: 0
+build_requires:
+ ExtUtils::MakeMaker: 0
+requires:
+ App::Options: 0
+ Class::Field: 0
+ HTTP::Request: 0
+ IPC::Run: 0
+ JSON::XS: 2.1
+ LWP::UserAgent: 0
+ Pod::Usage: 0
+ Readonly: 0
+ Test::Mock::LWP: 0.05
+ URI::Escape: 1.31
+no_index:
+ directory:
+ - t
+ - inc
+generated_by: ExtUtils::MakeMaker version 6.56
meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.3.html
- version: 1.3
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: 1.4
Modified: branches/upstream/libsocialtext-resting-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsocialtext-resting-perl/current/Makefile.PL?rev=63373&op=diff
==============================================================================
--- branches/upstream/libsocialtext-resting-perl/current/Makefile.PL (original)
+++ branches/upstream/libsocialtext-resting-perl/current/Makefile.PL Tue Oct 5 01:21:57 2010
@@ -9,7 +9,7 @@
'VERSION_FROM' => 'lib/Socialtext/Resting.pm',
'PREREQ_PRINT' => 1,
'EXE_FILES' => [
- 'bin/strut',
+ 'bin/strut', 'bin/st-webhook',
],
'PREREQ_PM' => {
'URI::Escape' => 1.31,
Added: branches/upstream/libsocialtext-resting-perl/current/bin/st-webhook
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsocialtext-resting-perl/current/bin/st-webhook?rev=63373&op=file
==============================================================================
--- branches/upstream/libsocialtext-resting-perl/current/bin/st-webhook (added)
+++ branches/upstream/libsocialtext-resting-perl/current/bin/st-webhook Tue Oct 5 01:21:57 2010
@@ -1,0 +1,90 @@
+#!/usr/bin/env perl
+# @COPYRIGHT@
+
+use strict;
+use warnings;
+use Socialtext::Resting::Getopt qw/get_rester/;
+use Getopt::Long;
+use JSON::XS;
+
+my $r = get_rester();
+usage("No rester server is specified!") unless $r->server;
+
+my %args;
+GetOptions( \%args,
+ 'class=s',
+ 'url=s',
+ 'id=s',
+ 'account-id=s',
+ 'workspace-id=s',
+);
+
+$args{account_id} = delete $args{'account-id'} if $args{'account-id'};
+$args{workspace_id} = delete $args{'workspace-id'} if $args{'workspace-id'};
+
+my $command = shift || usage();
+my %commands = (
+ create => sub {
+ usage("Must specify class and url.") unless $args{class} and $args{url};
+ my $id = $r->post_webhook( %args ) || '';
+ print "Created webhook $id\n";
+ },
+ list => sub {
+ my $hooks = $r->get_webhooks();
+ if (@$hooks) {
+ for my $h (@$hooks) {
+ next if $args{class} and $args{class} ne $h->{class};
+ dump_hook($h);
+ }
+ }
+ else {
+ print "No webhooks have been created.\n";
+ }
+ },
+ 'delete' => sub {
+ usage("Must specify a hook ID to delete") unless $args{id};
+ $r->delete_webhook(%args);
+ print "Webhook $args{id} deleted.\n";
+ },
+);
+
+my $sub = $commands{$command} || usage("Sorry, $command is not a valid command.");
+$sub->();
+
+exit;
+
+sub usage {
+ my $msg = shift || '';
+ $msg .= "\n\n" if $msg;
+ die <<EOT
+${msg}USAGE: $0 COMMAND --class=foo --url=foo
+
+Where COMMAND is one of:
+ create - create a new webhook
+ list - list existing webhooks
+ delete - delete a webhook
+
+Mandatory `create` arguments:
+ --class - class of events to hook
+ --url - URL the hook should GET when it fires
+
+Mandatory `delete` arguments:
+ --id - Webhook ID to delete
+
+Optional Webhook filter arguments:
+ --account-id=foo
+ --workspace-id=foo
+EOT
+}
+
+sub dump_hook {
+ my $h = shift;
+ print "ID: $h->{id} - $h->{class} - $h->{url}\n";
+ print " Creator user_id: $h->{creator_id}\n";
+ print " Workspace filter: $h->{workspace_id}\n" if $h->{workspace_id};
+ print " Account filter: $h->{account_id}\n" if $h->{account_id};
+ if (keys %{ $h->{details} }) {
+ print " Hook details:\n " . encode_json($h->{details}) . "\n";
+ }
+ print "\n";
+}
Propchange: branches/upstream/libsocialtext-resting-perl/current/bin/st-webhook
------------------------------------------------------------------------------
svn:executable = *
Modified: branches/upstream/libsocialtext-resting-perl/current/lib/Socialtext/Resting.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsocialtext-resting-perl/current/lib/Socialtext/Resting.pm?rev=63373&op=diff
==============================================================================
--- branches/upstream/libsocialtext-resting-perl/current/lib/Socialtext/Resting.pm (original)
+++ branches/upstream/libsocialtext-resting-perl/current/lib/Socialtext/Resting.pm Tue Oct 5 01:21:57 2010
@@ -11,7 +11,7 @@
use Readonly;
-our $VERSION = '0.30';
+our $VERSION = '0.34';
=head1 NAME
@@ -72,6 +72,7 @@
profile_photo => $BASE_URI . '/people/:pname/photo',
signals => $BASE_URI . '/signals',
webhooks => $BASE_URI . '/webhooks',
+ webhook => $BASE_URI . '/webhooks/:id',
);
field 'workspace';
@@ -91,6 +92,7 @@
field 'json_verbose';
field 'cookie';
field 'agent_string';
+field 'on_behalf_of';
=head2 new
@@ -1113,10 +1115,17 @@
$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_id => 142);
Posts a signal.
Optional C<account_ids> and C<group_ids> arguments for targetting the signal.
+
+Optional C<in_reply_to_id> for specifying a signal_id this signal is in reply to.
+
+Optional C<annotations> to annotate the signal. C<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.
=cut
@@ -1131,6 +1140,11 @@
my @ids = @{ $args{$k.'s'} || [] };
push @ids, $args{$k} if $args{$k}; # must be non-zero
$sig{$k.'s'} = \@ids if @ids;
+ }
+
+ for my $k (qw(in_reply_to annotations attachments)) {
+ next unless exists $args{$k};
+ $sig{$k} = $args{$k};
}
my $uri = $self->_make_uri('signals');
@@ -1152,31 +1166,81 @@
}
}
-=head2 put_webhook
-
- $Rester->put_webhook( %args )
+=head2 post_webhook
+
+ $Rester->post_webhook( %args )
Creates a webhook. Args will be encoded as JSON and put up.
=cut
-sub put_webhook {
+sub post_webhook {
my $self = shift;
my %args = @_;
my $uri = $self->_make_uri('webhooks');
my ( $status, $content, $response ) = $self->_request(
uri => $uri,
- method => 'PUT',
+ method => 'POST',
type => "application/json",
content => encode_json( \%args ),
);
- my $location = $response->header('location');
- $location = URI::Escape::uri_unescape($1);
-
if ( $status == 204 || $status == 201 ) {
- return $location;
+ return $response->header('Location');
+ }
+ else {
+ die "$status: $content\n";
+ }
+}
+
+=head2 get_webhooks
+
+ my $hooks = $Rester->get_webhooks();
+
+Returns an arrayref containing hashrefs of each webhook on the server.
+
+=cut
+
+sub get_webhooks {
+ my $self = shift;
+
+ my $uri = $self->_make_uri('webhooks');
+ my ( $status, $content, $response ) = $self->_request(
+ uri => $uri,
+ method => 'GET',
+ type => "application/json",
+ );
+
+ if ( $status == 200 ) {
+ return decode_json($content);
+ }
+ else {
+ die "$status: $content\n";
+ }
+}
+
+=head2 delete_webhook
+
+ $Rester->delete_webhook( id => $webhook_id );
+
+Deletes the specified webhook.
+
+=cut
+
+sub delete_webhook {
+ my $self = shift;
+ my %args = @_;
+ die "id is mandatory" unless $args{id};
+
+ my $uri = $self->_make_uri('webhook', {id => $args{id}});
+ my ( $status, $content, $response ) = $self->_request(
+ uri => $uri,
+ method => 'DELETE',
+ );
+
+ if ( $status == 204 ) {
+ return;
}
else {
die "$status: $content\n";
@@ -1202,6 +1266,8 @@
$request->header( 'Accept' => $p{accept} ) if $p{accept};
$request->header( 'Content-Type' => $p{type} ) if $p{type};
$request->header( 'If-Match' => $p{if_match} ) if $p{if_match};
+ $request->header( 'X-On-Behalf-Of' => $self->on_behalf_of ) if $self->on_behalf_of;
+
if ($p{method} eq 'PUT') {
my $content_len = 0;
$content_len = do { use bytes; length $p{content} } if $p{content};
More information about the Pkg-perl-cvs-commits
mailing list