diff options
author | Chad Roberts <croberts@redhat.com> | 2014-11-17 16:12:29 -0500 |
---|---|---|
committer | Chad Roberts <croberts@redhat.com> | 2014-11-17 16:26:03 -0500 |
commit | 36d8a134d679d9c0e6c9b09c3c1c584a32797cfb (patch) | |
tree | 874c8209f24c799613d1dc1c1e3de3220a896c7e /saharaclient/api/base.py | |
parent | 8cfc1d6a1fd7eda77ae3ab0407188ed28fce3210 (diff) | |
download | python-saharaclient-36d8a134d679d9c0e6c9b09c3c1c584a32797cfb.tar.gz |
Adding support for query filtering to list() calls
Each of the list() methods now supports an extra
parameter, search_opts, which is a dict that will
contain search fields and values to limit the result
sets. The changes here will also rely upon changes
to the Sahara service to support query-style
parameters.
Change-Id: I26986cbc153c3f8ad74b52d91086afbdfbd93926
Implements: bp enable-result-filtering
Diffstat (limited to 'saharaclient/api/base.py')
-rw-r--r-- | saharaclient/api/base.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/saharaclient/api/base.py b/saharaclient/api/base.py index c2c9c36..ee85c2d 100644 --- a/saharaclient/api/base.py +++ b/saharaclient/api/base.py @@ -17,6 +17,7 @@ import json import logging import six +from six.moves.urllib import parse from saharaclient.openstack.common.gettextutils import _ @@ -161,3 +162,12 @@ class APIException(Exception): self.error_code = error_code self.error_name = error_name self.error_message = error_message + + +def get_query_string(search_opts): + if search_opts: + qparams = sorted(search_opts.items(), key=lambda x: x[0]) + query_string = "?%s" % parse.urlencode(qparams) + else: + query_string = "" + return query_string
\ No newline at end of file |