= Dump == DESCRIPTION Query REST resource provides simple GET method to query for Portax subscription database. == METHODS === GET Query subscription. pn:: Limit query results to PN. unit_id:: Limit query results to UNIT_ID. offset:: Start dumping at offset N. limit:: Limit dump to size of N records. == EXAMPLES ==== Dump first 100 records. {{{ curl --user $USER:$PASS $URL/rest/query?offset=0&limit=100 }}} ==== Dump whole subscription database in batches of 100 records. {{{#!perl #!/usr/bin/env perl $| = 1; use strict; use warnings; use JSON; use LWP::UserAgent; use MIME::Base64; use Net::SSLeay; use constant URL => '...'; use constant USER => '...'; use constant PASS => '...'; my $ua = LWP::UserAgent->new(); $ua->default_header( "Content-type" => "application/json"); $ua->default_header( "Authorization" => join(" ", "Basic", MIME::Base64::encode( join(":", USER, PASS)))); my $results; my $offset = 0; my $limit = 100; my $j = JSON->new(); do { my $uri = URI->new( join('/', URL, 'rest/subscribers')); $uri->query_form( offset => $offset, limit => $limit); my $r = $ua->get($uri); die sprintf("request failed (%s)\n", $r->code) unless $r->code == 200; if( my $response = $j->decode( $r->decoded_content())) { if( $results = $response->{"results"}) { foreach my $item (@$results) { printf "%s: %s[#%s]\n", $offset, $item->{"pn"}, $item->{"id"}; } $offset += scalar @$results; } } } while (scalar @$results); }}}