Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Paging with REST::Client?

by Argel (Prior)
on Jan 13, 2020 at 16:42 UTC ( [id://11111360]=note: print w/replies, xml ) Need Help??


in reply to Re: Paging with REST::Client?
in thread Paging with REST::Client?

I'm not an expert on RESTful APIs, so I'm not sure what specifically is supplying the functionality, but it's on the server side of things. It's something passed in via the URL. Here's an example URL from some debug output I have lying around:
https://nios.mycompany.com/wapi/v2.7/range?network=10.20.30.0/24\&star +t_addr=10.20.30.40\&_return_fields%2B=disable,extattrs,network\&_pagi +ng=1\&_max_results=500\&_return_as_object=1

Elda Taluta; Sarks Sark; Ark Arks
My deviantART gallery

Replies are listed 'Best First'.
Re^3: Paging with REST::Client?
by bliako (Monsignor) on Jan 13, 2020 at 21:44 UTC

    just a shot in the dark, the server may be sending data keyed on "address" (10.20.30.40). In order to get to the next 500 results you have to use the last "address" you got from the last results page and send this as "start_addr".

    sort of! In the link below, the server returns a reference to send it back to get the next page: perhaps you can figure it out by searching for paging in this page: https://ipam.illinois.edu/wapidoc/additional/sample.html?highlight=paging

      Nice guess at the third party app!! Looking at my confusing old code, I don't think the query/search needs to change. You just have to pass in _next_page_id from the previous query in as _page_id in the new query. I'm not 100% on that as I haven't looked at this code in several months and there's a reason I wanted to get away from having to manually do the paging. It really could benefit from an OOP approach, and I was hoping there was a module that already handled it.

      Elda Taluta; Sarks Sark; Ark Arks
      My deviantART gallery

        finally we are getting somewhere :) Now get cracking on that OOP approach and please post it (or any questions you may have) here. Glad it was of help.

Re^3: Paging with REST::Client?
by 1nickt (Canon) on Jan 13, 2020 at 17:16 UTC

    Hi try adding &page=2


    The way forward always starts with a minimal test.
      Sorry, I should have been clear -- that's an example from my old Curl code. REST::Client isn't doing any of the paging.

      Elda Taluta; Sarks Sark; Ark Arks
      My deviantART gallery

        Umm, right. Rest::Client does not do any paging. You said that it's on the server. So that means that you will have to provide the parameters or headers necessary to Rest::Client in the call it makes, and write a wrapper that collates the results from the various requests.

        What does the documentation of the API you are calling say about paging?


        The way forward always starts with a minimal test.
Re^3: Paging with REST::Client?
by Anonymous Monk on Jan 14, 2020 at 01:06 UTC

    I'm not an expert on RESTful APIs, so I'm not sure what specifically is supplying the functionality, but it's on the server side of things. It's something passed in via the URL. Here's an example URL from some debug output I have lying around:

    Hi

    ;) Have you read what you wrote?

    Surely you know exactly the actions you took, cause you say

    "passed in via URL"

    Well, there you go, the module does accepts URLs https://metacpan.org/pod/REST::Client#GET-(-$url,-%5B%25$headers%5D-)

    So what happened when you did that (pass via url)?

    "paging" ain't nothing but a loop (foreach) where you ask for some more

      In theory I could pass in the paging parameters and see what REST::Client does with it, but I was hoping it supported it so it could be transparent to me -- i.e. just keep puling in thew data behind the scenes for me. Otherwise, it's back to some ugly code to deal with it. Maybe I can handle it slightly better than my Curl based scripts, but it adds a lot of complexity to the code just to handle something that feels like it should be part of the feature set of the module (e.g. a ->next function, or the abiltiy to tell it to slurp everything in).

      The "don't know" part -- I know the server side is handling the paging, but not sure what specifically is handling it (module in the web server, some process the WAPI calls are passed to, etc.).

      Elda Taluta; Sarks Sark; Ark Arks
      My deviantART gallery

        In theory I could pass in the paging parameters and see what REST::Client does with it, but I was hoping it supported it so it could be transparent to me -- i.e. just keep puling in thew data behind the scenes for me. Otherwise, it's back to some ugly code to deal with it. Maybe I can handle it slightly better than my Curl based scripts, but it adds a lot of complexity to the code just to handle something that feels like it should be part of the feature set of the module (e.g. a ->next function, or the abiltiy to tell it to slurp everything in).

        I suggest you read REST to see what it actually is.

        Same for REST::Client

        The "don't know" part -- I know the server side is handling the paging, but not sure what specifically is handling it (module in the web server, some process the WAPI calls are passed to, etc.).

        Is that like, I know gas gets gas delivered, but I dont know which refinery or how its delivered exactly?

        That is a baffling response to being asked which gas station.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11111360]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-25 22:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found