Paging in this context refers to pulling in a subset of data, then the next subset (page) of data, etc.

Yeah, thats a loop

Here's some documentation (not hosted by the vendor or the company I work for):

Ok, ask yourself, where is "Infoblox" mentioned in REST, REST::Client or LWP?

Or why it took take until Re^8 to link Infoblox ?

Vacation time or something

#!/usr/bin/perl -- use strict; use warnings; our @PAIRS; our %JSON; Main( @ARGV ); exit( 0 ); sub Main { %JSON = fromPairs(); my $startUrl = $PAIRS[0][0]; Paginate( $startUrl, sub { my( $json, $url ) = @_; ## real work here print "## callback @_ \n"; print $json->{result}[0]{name}, "\n\n"; }, ); return; } sub getAll { my @jsons; Paginate( $startUrl, sub { my( $json, $url ) = @_; push @jsons, $json; }, ); return \@jsons; } sub Paginate { my( $url, $callback )= @_; my @gets = $url; while( @gets ){ my $url = shift @gets; my $json = GET( $url ); if( my $id = $json->{next_page_id} ){ push @gets, urlNext( $url, $id, $json ); } $callback->( $json, $url ); } } sub urlNext { my( $url, $id, $json ) = @_; ## logic here return "https://127.0.0.1/wapi/v2.7.3/record:a?_page_id=$id"; } sub GET { ## real network request, REST::Client or whatever return $JSON{ $_[0] }; } sub fromPairs { @PAIRS = ( [ "https://127.0.0.1/wapi/v2.7.3/record:a?_max_results=2&_paging=1&_ +return_as_object=1&_return_fields=name&name~=test1.com", { next_page_id => "789c5590...4efc1732", result => [ { _ref => "record:a/ZG5zLmJpbmRfYSQuXY29tLn3DEwLjEuMC4x:a1.tes +t1.com/default", name => "a1.test1.com", }, { _ref => "record:a/ZG5zLmJpbmRLnRlc3QxLGE1LDEwLjEuMC41:a5.tes +t1.com/default", name => "a5.test1.com", }, ], }, ], [ "https://127.0.0.1/wapi/v2.7.3/record:a?_page_id=789c5590...4efc17 +32", { next_page_id => "789c5590...3e113c3d4d", result => [ { _ref => "record:a/ZG5zLmJpbmRfYSQc3QxLGE0LDEwLjEuMC40:a4.tes +t1.com/default", name => "a4.test1.com", }, { _ref => "record:a/ZG5zLmuY29tLnRlc3QxLGEzLDEwLjEuMC4z:a3.tes +t1.com/default", name => "a3.test1.com", }, ], }, ], [ "https://127.0.0.1/wapi/v2.7.3/record:a?_page_id=789c5590...3e113c +3d4d", { result => [ { _ref => "record:a/ZG5zLmJpbmRfYSQuX2RLGEyLDEwLjEuMC4y:a2.tes +t1.com/default", name => "a2.test1.com", }, ], }, ], ); return map { @$_ } @PAIRS; }

In reply to Re^9: Paging with REST::Client? by Anonymous Monk
in thread Paging with REST::Client? by Argel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.