Perl API trying to use limit

Posts: 127
3799     0


Trying to write in Perl, getting list of devices by limited page.  Limiting the number of records returned works in the NetMRI API, and also in Python, but I can't get it to work in Perl.  It seems to always return the entire number of devices in the group, and doesn't repect the limit.  Below is a couple lines of code from the script:

my @devices = $client->broker->device->index({
            DeviceGroupID => 38,
            select => [qw( DeviceID DeviceName DeviceIPDotted DeviceModel DeviceVersion DeviceType VirtualInd DeviceMAC )],
print "Max Index: $#devices\n";


The plan was to increment through all of the devices by 10, but this always returns (in my case, 538).  $startRecord begins at 1, 11, 21, etc.


Anyone have experience with this?  I've tried this on 7.1.2 and 7.2.1, 3.1 api. It seems to just ignore the limit value.




Re: Perl API trying to use limit

Posts: 14
3800     0

I'm not sure why it is done that way, but it looks like when index method is called in array context Perl API actually iterates the list with pagination using provided limit and start under the hood making API call for each page, but returning the whole list in result. But if it is called in scalar context like "my $devices = $client->broker->device->index(...)" it seems to be working as you expect. Could you please try this workaround?

Showing results for 
Search instead for 
Did you mean: 

Recommended for You