Difference between revisions of "API Special Interest Group/Current Design/Sorting"
Line 1: | Line 1: | ||
= Analysis = | = 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 | + | 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 | + | The following sort direction values are supported: |
{| class="wikitable" | {| class="wikitable" | ||
Line 13: | Line 13: | ||
| desc || Descending 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.: | 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.: | ||
Line 22: | Line 24: | ||
= 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. | + | 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. | Some projects also append default sort keys to the list of user-defined keys. | ||
Line 47: | Line 49: | ||
== Nova == | == Nova == | ||
− | Supports fewer sort directions supplied then sort keys; any keys without an | + | Supports fewer sort directions supplied then sort keys; any keys without an associated direction have a default direction applied. |
== Neutron == | == Neutron == |
Revision as of 22:09, 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 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 |
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.