Automation Scripts

Reply
Highlighted

Perl API trying to use limit

Expert
Posts: 111
1392     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,
            start=>$startRecord,
            limit=>10,
            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.

 

Thanks,

Lon.

Re: Perl API trying to use limit

skuchynski
Techie
Posts: 8
1393     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 
Do you mean 

Recommended for You