Skip to end of metadata
Go to start of metadata

Retrieve Group History

#!/usr/bin/perl
use REST::Client;
use XML::LibXML;

my $ssl_cert = 'my-app.cert';
my $ssl_key = 'my-app.key';
my $ssl_ca = '/usr/local/ssl/certs/cacerts.cert';

my $gws_host = 'https://iam-ws.u.washington.edu:7443';
my $rest_timeout = 20;

my $client = REST::Client->new({
  host    => $gws_host,
  cert    => $ssl_cert,
  key     => $ssl_key,
  ca      => $ssl_ca,
  timeout => $rest_timeout,
});

my $group = $ARGV[0];
my $rest_query = '/group/'.$group.'/history?size=999999';
$client->GET($rest_query);
my $rc = $client->responseCode();
my $raw_html = $client->responseContent();
&check_rest($gws_host.$rest_query,$rc,$raw_html,__LINE__);
my $doc_hist = XML::LibXML->new->parse_html_string($raw_html);
my $query = "//*[\@class='history']";
foreach my $node ($doc_hist->findnodes($query)) {
  my $activity = $node->getAttribute("activity");
  my $unixtime_ms = $node->getAttribute("date");
  my $raction = $node->getAttribute("description");
  my($action,$user) = $raction =~ /(.+): \'(.+)\'/;
  if($activity eq "membership" && $action eq "add member") {
    print "$user => $unixtime_ms\n";
  }
}

sub check_rest($$$$) {
  my($query,$rc,$output,$line) = @_;
  if($rc != 200) {
    print "Line $line: REST GET ($query) failed: RC $rc\n";
    die "$output\n";
  }
}

Retrieve Effective Members

#!/usr/bin/perl
use REST::Client;
use XML::LibXML;

my $ssl_cert = 'my-app.cert';
my $ssl_key = 'my-app.key';
my $ssl_ca = '/usr/local/ssl/certs/cacerts.cert';

my $gws_host = 'https://iam-ws.u.washington.edu:7443';
my $rest_timeout = 20;

my $client = REST::Client->new({
  host    => $gws_host,
  cert    => $ssl_cert,
  key     => $ssl_key,
  ca      => $ssl_ca,
  timeout => $rest_timeout,
});

my $group = $ARGV[0];
my $rest_query = '/group/'.$group.'/effective_member';
$client->GET($rest_query);
my $rc = $client->responseCode();
my $raw_html = $client->responseContent();
&check_rest($gws_host.$rest_query,$rc,$raw_html,__LINE__);
my $doc_mem = XML::LibXML->new->parse_html_string($raw_html);
my $query = "//*[\@class='effective_member']";
foreach my $node ($doc_mem->findnodes($query)) {
  my $member = $node->to_literal;
  my $type = $node->getAttribute("type");
  if($type ne "uwnetid") { next; }
  print "$member\n";
}

sub check_rest($$$$) {
  my($query,$rc,$output,$line) = @_;
  if($rc != 200) {
    print "Line $line: REST GET ($query) failed: RC $rc\n";
    die "$output\n";
  }
}