Jump to: navigation, search

Difference between revisions of "Cinder Pagination"

Line 4: Line 4:
 
== Proposal ==
 
== Proposal ==
 
=== Multiple sort keys and directions ===
 
=== Multiple sort keys and directions ===
The ''/servers'' and ''/servers/detail'' APIs will support the following parameters being repeated on the request:
+
The ''/servers'' and ''/servers/detail'' APIs will support the following parameters being repeated on the request.  This implementation eliminates the need to define a token for separating multiple values from a single request parameter.
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-

Revision as of 15:59, 20 March 2014

Overview

Pagination allows for retrieving a limited number of results instead of the entire data set. The cinder /volumes and /volumes/detail APIs support pagination and support a single sort key and sort direction.

Proposal

Multiple sort keys and directions

The /servers and /servers/detail APIs will support the following parameters being repeated on the request. This implementation eliminates the need to define a token for separating multiple values from a single request parameter.

Parameter Description
sort_key Key used to determine sort order
sort_dir Direction for with the associated sort key (asc or desc)

The caller can specify these parameters multiple times in order to generate a list of sort keys and sort directions. The first key listed is the primary key, the next key is the secondary key, etc.
For example: /volumes?sort_key=status&sort_key=display_name&sort_key=created_at&sort_dir=desc&sort_dir=desc&sort_dir=desc
Note: The created_at and id sort keys are always appended at the end of the key list (descending sort order) if they are not already specified on the request.

Implementation Details

Multiple sort keys and directions

The database layer already supports multiple sort keys and sort directions (see paginate_query function in sqlalchemyutils.py). The layers above this need to be modified to accept a list of sort keys and sort direction. Also, a function needs to be added to create the list of sort keys and directions from the request parameters.

Retailed Blueprints

Nova

The same enhancements are being proposed in nova: Nova Pagination