Jump to: navigation, search

Difference between revisions of "API Special Interest Group/Current Design/Sorting"

m (EdLeafe moved page API Working Group/Current Design/Sorting to API Special Interest Group/Current Design/Sorting: +The group changed its name and focus)
 
(3 intermediate revisions by one other user not shown)
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 sory keys and directions.
+
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 directions values are supported:
+
The following sort direction values are supported:
  
 
{| class="wikitable"
 
{| class="wikitable"
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) and 'key2' to be the second sort key (in 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.:
  
 
<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 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:
 +
 +
{| 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
 +
|-
 +
| Heat|| Multiple || Single ||  'created_at', 'id' || desc
 +
|}
 +
 +
Additional project-specific information can be found below.
  
 
== Nova ==
 
== Nova ==
  
Nova supports multiple sort keys and multiple sort directions.
+
Supports fewer sort directions supplied then sort keys; any keys without an associated direction have a default direction applied.
  
 
== Neutron ==
 
== Neutron ==
  
Neutron supports multiple sort keys and multiple sort directions.
+
Requires an equal number of sort keys and sort directions.
  
 
== Cinder ==
 
== Cinder ==
  
Cinder supports a single sort key and a single sort direction.
+
[https://blueprints.launchpad.net/cinder/+spec/cinder-pagination This BP] proposes support for multiple sort keys and multiple sort directions
  
Note: [https://blueprints.launchpad.net/cinder/+spec/cinder-pagination This BP] proposes support for multiple sort keys and multiple sort directions
+
== Glance ==
 
 
== Ironic ==
 
  
Ironic supports a single sort key and a single sort direction.
+
Glance supports a multiple sort keys and a single sort direction; the sort direction is applied to all keys.
  
== Glance ==
+
== Heat ==
  
Glance supports a multiple sort keys and a single sort direction.
+
Heat supports a multiple sort keys and a single sort direction; the sort direction is applied to all keys.

Latest revision as of 15:40, 14 June 2018

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.