Difference between revisions of "API Special Interest Group/Current Design/Sorting"
Line 14: | Line 14: | ||
|} | |} | ||
− | 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) | + | 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.: |
<pre><nowiki> | <pre><nowiki> | ||
− | sort_key=key1&sort_dir=asc&sort_key=key2&sort_dir=desc | + | sort_key=key1&sort_dir=asc&sort_key=key2&sort_dir=desc&sort_key=key3&sort_dir=asc |
</nowiki></pre> | </nowiki></pre> | ||
= Current Design = | = Current Design = | ||
+ | |||
+ | The REST APIs 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: | ||
+ | |||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! 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 | ||
+ | |} | ||
+ | |||
+ | Additional project-specific information can be found below. | ||
== Nova == | == Nova == | ||
− | + | Supports fewer sort directions supplied then sort keys; any keys without an explicitly defined sort direction have a default sort direction applied. | |
== Neutron == | == Neutron == | ||
− | + | Requires an equal number of sort keys and sort directions. | |
== Cinder == | == Cinder == | ||
− | + | [https://blueprints.launchpad.net/cinder/+spec/cinder-pagination This BP] proposes support for multiple sort keys and multiple sort directions | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Glance == | == Glance == | ||
− | Glance supports a multiple sort keys and a single sort direction. | + | Glance supports a multiple sort keys and a single sort direction; the sort direction is applied to all keys. |
Revision as of 21:59, 12 January 2015
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 sory keys and directions.
The following sort directions values are supported:
Value | Description |
---|---|
asc | Ascending Order |
desc | Descending Order |
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 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 |
Additional project-specific information can be found below.
Nova
Supports fewer sort directions supplied then sort keys; any keys without an explicitly defined sort direction have a default sort 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.