Jump to: navigation, search

API Working Group/Current Design/Sorting

Analysis

Sorting is determined through the use of the 'sort_key' and 'sort_dir' query string parameters; the caller can specify these multiple times in order to generate a list of sort keys and directions.

The following sort direction values are supported:

Value Description
asc Ascending Order
desc Descending Order

The valid sort keys are based on the project's data model.

The sort keys and directions are applied in the order in which they are specified as query string parameters. For example, the following specifies 'key1' to be the first sort key (in ascending order), 'key2' to be the second sort key (in descending order), etc.:

sort_key=key1&sort_dir=asc&sort_key=key2&sort_dir=desc&sort_key=key3&sort_dir=asc

Current Design

The REST APIs for the projects listed below support sort keys and sort directions to varying degrees, ranging from multiple keys and directions to a single key and a single direction.

Some projects also append default sort keys to the list of user-defined keys.

The table below summarizes the current behavior:

Project Number of Sort Keys Number of Sort Directions Default Keys Default Direction
Nova Multiple Multiple 'created_at', 'id' desc
Neutron Multiple Multiple None None
Cinder Single Single 'created_at', 'id' desc
Ironic Single Single 'id' asc
Glance Multiple Single 'created_at', 'id' desc
Heat Multiple Single 'created_at', 'id' desc

Additional project-specific information can be found below.

Nova

Supports fewer sort directions supplied then sort keys; any keys without an associated direction have a default direction applied.

Neutron

Requires an equal number of sort keys and sort directions.

Cinder

This BP proposes support for multiple sort keys and multiple sort directions

Glance

Glance supports a multiple sort keys and a single sort direction; the sort direction is applied to all keys.

Heat

Heat supports a multiple sort keys and a single sort direction; the sort direction is applied to all keys.