You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cloudstack.apache.org by Nik Martin <ni...@nfinausa.com> on 2013/01/11 16:51:44 UTC
Usage API Paging question
Could someone post some pseudocode on how to use paging when processing
usage reports? I'm having a bit of trouble getting my head wrapped around
this.
Here's pseudocode for what I have right now:
default.page.size: 2000
var page=1
usage = api.listusage{domain:xxx, page:page, pagesize: 2000,
startdate:xx-xx-xxxx, enddate: xx-xx-xxxx};
while usage.length = 2000{
//there are more records
page+=1;
usage= usage + api.listusage{domain:xxx, page:page, pagesize:
2000,
startdate:xx-xx-xxxx, enddate: xx-xx-xxxx};
}
Is this in line with what I should be doing? As long as the number of
records is 2000, it can be assumes that there are more records, so I
should fetch until usage.length < 2000.
Regards,
Nik
Nik Martin
+1.251.243.0043 x1003
Relentless Reliability
RE: Usage API Paging question
Posted by Kishan Kavala <Ki...@citrix.com>.
> -----Original Message-----
> From: Nik Martin [mailto:nik.martin@nfinausa.com]
> Sent: Friday, 11 January 2013 9:22 PM
> To: cloudstack-users@incubator.apache.org
> Subject: Usage API Paging question
>
> Could someone post some pseudocode on how to use paging when
> processing usage reports? I'm having a bit of trouble getting my head
> wrapped around this.
>
> Here's pseudocode for what I have right now:
> default.page.size: 2000
>
> var page=1
> usage = api.listusage{domain:xxx, page:page, pagesize: 2000, startdate:xx-
> xx-xxxx, enddate: xx-xx-xxxx};
>
> while usage.length = 2000{
> //there are more records
> page+=1;
> usage= usage + api.listusage{domain:xxx, page:page, pagesize:
> 2000,
> startdate:xx-xx-xxxx, enddate: xx-xx-xxxx}; }
[KK] This should instead be: usage= api.listusage{domain:xxx, page:page, pagesize: 2000, startdate:xx-xx-xxxx, enddate: xx-xx-xxxx};
>
> Is this in line with what I should be doing? As long as the number of records
> is 2000, it can be assumes that there are more records, so I should fetch until
> usage.length < 2000.
>
[KK] Yes, you need to fetch until length < 2000
>
> Regards,
>
> Nik
>
> Nik Martin
> +1.251.243.0043 x1003
> Relentless Reliability