summaryrefslogtreecommitdiff
path: root/saharaclient/api/base.py
diff options
context:
space:
mode:
authorMikhail Lelyakin <mlelyakin@mirantis.com>2016-08-04 12:51:44 +0300
committerMikhail Lelyakin <mlelyakin@mirantis.com>2016-08-04 13:44:06 +0300
commitf3b00004b01e5ad1e17ae82d91c72ea5bc9dd70c (patch)
tree3b846bc90a389bb073e0c176765a237edf6de03c /saharaclient/api/base.py
parent91f80b12688cc2f0784a23dec958a69437175f55 (diff)
downloadpython-saharaclient-f3b00004b01e5ad1e17ae82d91c72ea5bc9dd70c.tar.gz
Add sorting ability to Python-saharaclient
Now we are working on pagination and sorting ability in Sahara API. This changes support work with sorting abilities. Change-Id: I824690f106bd81cc2ee949a65ba129c7ccf21d90 bp: pagination Depends-on: Icb83422a516961acd7c1c20a88cb0bb816c6bc81
Diffstat (limited to 'saharaclient/api/base.py')
-rw-r--r--saharaclient/api/base.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/saharaclient/api/base.py b/saharaclient/api/base.py
index aae3211..36c9e45 100644
--- a/saharaclient/api/base.py
+++ b/saharaclient/api/base.py
@@ -251,12 +251,18 @@ class APIException(Exception):
self.error_message = error_message
-def get_query_string(search_opts, limit=None, marker=None):
+def get_query_string(search_opts, limit=None, marker=None, sort_by=None,
+ reverse=None):
opts = {}
if marker is not None:
opts['marker'] = marker
if limit is not None:
opts['limit'] = limit
+ if sort_by is not None:
+ if reverse:
+ opts['sort_by'] = "-%s" % sort_by
+ else:
+ opts['sort_by'] = sort_by
if search_opts is not None:
opts.update(search_opts)
if opts: