sonata-nfv / son-catalogue-repos

SONATA's Service Platform Catalogue and Repository
http://www.sonata-nfv.eu
Apache License 2.0
4 stars 10 forks source link

Provide total record count in the metadata section #155

Closed jbonnet closed 7 years ago

jbonnet commented 7 years ago

Hey, @dang03 In order to implement pagination cleanly, one option is to get the total number of records on a given entity in the answer to a query.

What do you think? Do you already provide this, in a HTTP header, e.g.?

Please note that we're already using limit (number of records per page, default 10) and offset (number of page, default 0). For me, that total number of records should be the number of records that are present in the database, without forcing any limit.

dang03 commented 7 years ago

Hi @jbonnet , Catalogues-Repos' answers provides pagination in the HTTP header, however it only implements limit and offset (set to 10 too), but no links to next or previous pages. Perhaps we can set X-total-count header easily with the total number of records. Would this be useful to you or you prefer to have the total record count in other way?

jbonnet commented 7 years ago

Hello, again,

We’re implementing the links header on the API side: I think that it’s where that belongs, as long as the remaining modules provide this information.

My suggestion for the header is Record-Count since:

the X- is getting old-fashioned

calling it total-something might lead to error, since we might not be returning the total-total (e.g., when we pass …/services?author=i2CAT&limit=2 and i2CAT has authored 10 services/versions of the total 100 services/versions, Record-Count would return 10 — not 100 — and the query just 2 — the limit). Is this ok?

On 31 Jan 2017, at 13:17, Daniel notifications@github.com wrote:

Hi @jbonnet https://github.com/jbonnet , Catalogues-Repos' answers provides pagination in the HTTP header, however it only implements limit and offset (set to 10 too), but no links to next or previous pages. Perhaps we can set X-total-count header easily with the total number of records. Would this be useful to you or you prefer to have the total record count in other way?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sonata-nfv/son-catalogue-repos/issues/155#issuecomment-276360332, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAuQ7RLH2POR4oJiTVwcWk0v6Uen4rCks5rXzR-gaJpZM4LyjHB.

dang03 commented 7 years ago

Hi! Yes, it is fine. I have tested it and it only requires a minor tweak on each descriptor type APIs. Here is an example for functions:

curl -X GET HEAD -i -H "Content-Type: application/json" "http://0.0.0.0:4011/catalogues/api/v2/vnfs"

HTTP/1.1 200 OK Content-Type: text/html;charset=utf-8 Record-Count: 22 ...others... Content-Length: 11072

So it will be available for this new release.