Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #300 from shenrie/master

Enhance list_queues to take optional column filtering
  • Loading branch information...
commit 34c05869aae315d84a11b9611fda3000d4528c17 2 parents 688c591 + c614662
@daf daf authored
Showing with 17 additions and 9 deletions.
  1. +1 −1  extern/ion-definitions
  2. +16 −8 pyon/ion/exchange.py
2  extern/ion-definitions
@@ -1 +1 @@
-Subproject commit 3c5595309b677053b987e2f0e69d74dc860400df
+Subproject commit f8265fc1f872924ad4d6818dc90977608d201216
View
24 pyon/ion/exchange.py
@@ -558,30 +558,38 @@ def _list_exchanges(self):
return raw_exchanges
- def list_queues(self, name=None):
+ def list_queues(self, name=None, return_columns=None):
"""
Rabbit HTTP management API call to list names of queues on the broker.
- Returns a list of queue names. If you want the full properties for each,
- use _list_queues.
+ Returns a list of queue names. Can specify an optional list of
+ column names to filter the data returned from the API query. If you want
+ the full properties for each, use _list_queues.
@param name If set, filters the list by only including queues with name in them.
"""
- raw_queues = self._list_queues()
+ raw_queues = self._list_queues(return_columns)
nl = lambda x: (name is None) or (name is not None and name in x)
- queues = [x['name'] for x in raw_queues if nl(x['name'])]
+ if return_columns is None:
+ queues = [x['name'] for x in raw_queues if nl(x['name'])]
+ else:
+ queues = [x for x in raw_queues if nl(x['name'])]
return queues
- def _list_queues(self):
+ def _list_queues(self, return_columns=None):
"""
- Rabbit HTTP management API call to list queues with full properties.
+ Rabbit HTTP management API call to list queues with full properties. Can specify an optional list of
+ column names to filter the data returned from the API query.
This is used by list_queues to get a list of names, but does not filter anything.
"""
- url = self._get_management_url("queues", "%2f")
+ feats = "%2f"
+ if isinstance(return_columns, list):
+ feats += "?columns=" + ','.join(return_columns)
+ url = self._get_management_url("queues", feats)
raw_queues = self._call_management(url)
return raw_queues
Please sign in to comment.
Something went wrong with that request. Please try again.