<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">The only thing I want to caution against is making a SQL-specific choice. In the case of some other backends, it may not be possible (for an extremely large dataset) to get a full count, where SQL does this fairly elegantly. For example, LDAP (in some cases) may have an administrative limit that will say that no more than 10,000 entries would be returned; likely you’re going to have an issue, since you need to issue the query and see how many things match, if you hit the overall limit you’ll get the same count every time (but possibly a different dataset).</div><div class=""><br class=""></div><div class="">I want to be very careful that we’re not recommending functionality as a baseline that should be used as a pattern across all similar APIs, especially since we have some backends/storage systems that can’t elegantly always support it.</div><div class=""><br class=""></div><div class="">Personally, I like Gerrit’s model (as Sean described) - with the above caveat that not all backends support this type of count.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Morgan</div><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 20, 2014, at 8:04 AM, Salvatore Orlando <<a href="mailto:sorlando@nicira.com" class="">sorlando@nicira.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">The Nova proposal appears to be identical to neutron's, at least from a consumer perspective.<div class=""><br class=""></div><div class="">If I were to pick a winner, I'd follow Sean's advice regarding the 'more' attribute in responses, and put the total number of resources there; I would also take Jay's advice of including the total only if requested with a query param. In this way a user can retrieve the total number of items regardless of the current pagination index (in my first post I suggested the total number should be returned only on the first page of results).</div><div class=""><br class=""></div><div class="">Therefore one could ask for a total number of resources with something like the following:</div><div class=""><br class=""></div><div class="">GET /some_resources?include_total=1</div><div class=""><br class=""></div><div class="">and obtain a response like the following:</div><div class=""><br class=""></div><div class=""><span class="im" style="font-family:arial,sans-serif;font-size:13px">{'resources': [{meh}, {meh}, {meh_again}],</span></div><div class=""><span class="im" style="font-family:arial,sans-serif;font-size:13px">  'something': {</span></div><div class=""><span class="im" style="font-family:arial,sans-serif;font-size:13px">       '_links': {'prev': ..., 'next': ...},</span></div><div class=""><span class="im" style="font-family:arial,sans-serif;font-size:13px">       'total': agazillion}</span></div><div class=""><span class="im" style="font-family:arial,sans-serif;font-size:13px"> }<br class=""></span><br class=""></div><div class=""><font face="arial, sans-serif" class=""> where the exact structure and naming of 'something' depends on the outcome of the discussion at [1]</font></div><div class=""><font face="arial, sans-serif" class=""><br class=""></font></div><div class=""><font face="arial, sans-serif" class="">Salvatore</font></div><div class=""><font face="arial, sans-serif" class=""><br class=""></font></div><div class=""><font face="arial, sans-serif" class="">[1] <a href="https://review.openstack.org/#/c/133660/7/guidelines/representation_structure.rst" class="">https://review.openstack.org/#/c/133660/7/guidelines/representation_structure.rst</a></font></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On 20 November 2014 15:24, Christopher Yeoh <span dir="ltr" class=""><<a href="mailto:cbkyeoh@gmail.com" target="_blank" class="">cbkyeoh@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, 20 Nov 2014 14:47:16 +0100<br class="">
Salvatore Orlando <<a href="mailto:sorlando@nicira.com" class="">sorlando@nicira.com</a>> wrote:<br class="">
<br class="">
> Aloha guardians of the API!<br class="">
><br class="">
> I haven recently* reviewed a spec for neutron [1] proposing a<br class="">
> distinct URI for returning resource count on list operations.<br class="">
> This proposal is for selected neutron resources, but I believe the<br class="">
> topic is general enough to require a guideline for the API working<br class="">
> group. Your advice is therefore extremely valuable.<br class="">
><br class="">
> In a nutshell the proposal is to retrieve resource count in the<br class="">
> following way:<br class="">
> GET /<prefix>/<resource_name>/count<br class="">
><br class="">
> In my limited experience with RESTful APIs, I've never encountered<br class="">
> one that does counting in this way. This obviously does not mean it's<br class="">
> a bad idea. I think it's not great from a usability perspective to<br class="">
> require two distinct URIs to fetch the first page and then the total<br class="">
> number of elements. I reckon the first response page for a list<br class="">
> operation might include also the total count. For example:<br class="">
><br class="">
> {'resources': [{meh}, {meh}, {meh_again}],<br class="">
>  'resource_count': 55<br class="">
>  <link_to_next_page>}<br class="">
><br class="">
> I am however completely open to consider other alternatives.<br class="">
> What is your opinion on this matter?<br class="">
<br class="">
</div></div>FWIW there is a nova spec proposed for counting resources as<br class="">
well (I think it might have been previously approved for Juno).<br class="">
<br class="">
<a href="https://review.openstack.org/#/c/134279/" target="_blank" class="">https://review.openstack.org/#/c/134279/</a><br class="">
<br class="">
I haven't compared the two, but I can't think of a reason we'd<br class="">
need to be any different between projects here.<br class="">
<br class="">
Regards,<br class="">
<br class="">
Chris<br class="">
<span class="im HOEnZb"><br class="">
><br class="">
> Regards,<br class="">
> Salvatore<br class="">
><br class="">
><br class="">
> * it's been 10 days now<br class="">
><br class="">
> [1] <a href="https://review.openstack.org/#/c/102199/" target="_blank" class="">https://review.openstack.org/#/c/102199/</a><br class="">
<br class="">
<br class="">
</span><div class="HOEnZb"><div class="h5">_______________________________________________<br class="">
OpenStack-dev mailing list<br class="">
<a href="mailto:OpenStack-dev@lists.openstack.org" class="">OpenStack-dev@lists.openstack.org</a><br class="">
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank" class="">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br class="">
</div></div></blockquote></div><br class=""></div>
_______________________________________________<br class="">OpenStack-dev mailing list<br class=""><a href="mailto:OpenStack-dev@lists.openstack.org" class="">OpenStack-dev@lists.openstack.org</a><br class="">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev<br class=""></div></blockquote></div><br class=""></body></html>