This file is indexed.

/usr/bin/st-webhook is in libsocialtext-resting-perl 0.38-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/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',
    'group-id=s',
);

$args{account_id}   = delete $args{'account-id'}   if $args{'account-id'};
$args{workspace_id} = delete $args{'workspace-id'} if $args{'workspace-id'};
$args{group_id}     = delete $args{'group-id'}     if $args{'group-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";
}

=pod

=head1 NAME

st-webhook - tool to create/list/delete webhooks into the Socialtext REST services

=head1 SYNOPSIS

st-webhook 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

=head1 AUTHORS

This POD was created for the Debian package of Socialtext-Resting
from the help output of st-webhook by
Florian Schlichting <fschlich@zedat.fu-berlin.de>.