2014-12-17 10:14:37 -06:00
|
|
|
=====================
|
|
|
|
Paginated collections
|
|
|
|
=====================
|
|
|
|
|
|
|
|
To reduce load on the service, list operations return a maximum number
|
|
|
|
of items at a time. The maximum number of items returned is determined
|
2018-11-06 17:57:31 +09:00
|
|
|
by the compute provider. To navigate the collection, the ``limit`` and
|
|
|
|
``marker`` parameters can be set in the URI. For example:
|
2014-12-17 10:14:37 -06:00
|
|
|
|
|
|
|
.. code::
|
|
|
|
|
|
|
|
?limit=100&marker=1234
|
|
|
|
|
2018-11-06 17:57:31 +09:00
|
|
|
The ``marker`` parameter is the ID of the last item in the previous
|
2014-12-17 10:14:37 -06:00
|
|
|
list. By default, the service sorts items by create time in descending order.
|
2016-02-15 14:42:02 +00:00
|
|
|
When the service cannot identify a create time, it sorts items by ID. The
|
2018-11-06 17:57:31 +09:00
|
|
|
``limit`` parameter sets the page size. Both parameters are optional. If the
|
|
|
|
client requests a ``limit`` beyond one that is supported by the deployment
|
2014-12-17 10:14:37 -06:00
|
|
|
an overLimit (413) fault may be thrown. A marker with an invalid ID returns
|
|
|
|
a badRequest (400) fault.
|
|
|
|
|
|
|
|
For convenience, collections should contain atom ``next``
|
|
|
|
links. They may optionally also contain ``previous`` links but the current
|
|
|
|
implementation does not contain ``previous`` links. The last
|
2016-02-15 14:42:02 +00:00
|
|
|
page in the list does not contain a link to "next" page. The following examples
|
2017-12-15 15:23:09 +08:00
|
|
|
illustrate three pages in a collection of servers. The first page was
|
2014-12-17 10:14:37 -06:00
|
|
|
retrieved through a **GET** to
|
2018-11-06 17:57:31 +09:00
|
|
|
`http://servers.api.openstack.org/v2.1/servers?limit=1`. In these
|
2014-12-17 10:14:37 -06:00
|
|
|
examples, the *``limit``* parameter sets the page size to a single item.
|
|
|
|
Subsequent links honor the initial page size. Thus, a client can follow
|
|
|
|
links to traverse a paginated collection without having to input the
|
2018-11-06 17:57:31 +09:00
|
|
|
``marker`` parameter.
|
2014-12-17 10:14:37 -06:00
|
|
|
|
|
|
|
|
2018-08-03 09:56:59 +08:00
|
|
|
**Example: Servers collection: JSON (first page)**
|
2014-12-17 10:14:37 -06:00
|
|
|
|
|
|
|
.. code::
|
|
|
|
|
|
|
|
{
|
|
|
|
"servers_links":[
|
|
|
|
{
|
2016-08-16 16:17:03 -07:00
|
|
|
"href":"https://servers.api.openstack.org/v2.1/servers?limit=1&marker=fc45ace4-3398-447b-8ef9-72a22086d775",
|
2014-12-17 10:14:37 -06:00
|
|
|
"rel":"next"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"servers":[
|
|
|
|
{
|
|
|
|
"id":"fc55acf4-3398-447b-8ef9-72a42086d775",
|
|
|
|
"links":[
|
|
|
|
{
|
2016-08-16 16:17:03 -07:00
|
|
|
"href":"https://servers.api.openstack.org/v2.1/servers/fc45ace4-3398-447b-8ef9-72a22086d775",
|
2014-12-17 10:14:37 -06:00
|
|
|
"rel":"self"
|
|
|
|
},
|
|
|
|
{
|
2016-08-16 16:17:03 -07:00
|
|
|
"href":"https://servers.api.openstack.org/v2.1/servers/fc45ace4-3398-447b-8ef9-72a22086d775",
|
2014-12-17 10:14:37 -06:00
|
|
|
"rel":"bookmark"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"name":"elasticsearch-0"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
In JSON, members in a paginated collection are stored in a JSON array
|
|
|
|
named after the collection. A JSON object may also be used to hold
|
|
|
|
members in cases where using an associative array is more practical.
|
|
|
|
Properties about the collection itself, including links, are contained
|
|
|
|
in an array with the name of the entity an underscore (\_) and
|
|
|
|
``links``. The combination of the objects and arrays that start with the
|
|
|
|
name of the collection and an underscore represent the collection in
|
|
|
|
JSON. The approach allows for extensibility of paginated collections by
|
2017-12-15 15:23:09 +08:00
|
|
|
allowing them to be associated with arbitrary properties.
|