diff options
author | huangtianhua <huangtianhua@huawei.com> | 2014-07-07 17:24:26 +0800 |
---|---|---|
committer | huangtianhua <huangtianhua@huawei.com> | 2014-07-23 12:36:37 +0000 |
commit | 6eb45625e584f410fdb33d82c63916750650505d (patch) | |
tree | 0af24f5feda8052afd5255f811ca01d72d5b59f2 /heatclient/v1/events.py | |
parent | a98c1f3617604c4871263ff9cc986b27f302ef46 (diff) | |
download | python-heatclient-6eb45625e584f410fdb33d82c63916750650505d.tar.gz |
Implement events pagination, sorting and filtering
It supports pagination for events-list.
Implements blueprint events-pagination-heatclient
Change-Id: I11ca89b0a203435ba3793d061d7d06cb458d61eb
Diffstat (limited to 'heatclient/v1/events.py')
-rw-r--r-- | heatclient/v1/events.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/heatclient/v1/events.py b/heatclient/v1/events.py index e4cbcfd..f63d30c 100644 --- a/heatclient/v1/events.py +++ b/heatclient/v1/events.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +import six from six.moves.urllib import parse from heatclient.openstack.common.apiclient import base @@ -39,20 +40,32 @@ class Event(base.Resource): class EventManager(stacks.StackChildManager): resource_class = Event - def list(self, stack_id, resource_name=None): + def list(self, stack_id, resource_name=None, **kwargs): """Get a list of events. :param stack_id: ID of stack the events belong to :param resource_name: Optional name of resources to filter events by :rtype: list of :class:`Event` """ + params = {} + if 'filters' in kwargs: + filters = kwargs.pop('filters') + params.update(filters) + + for key, value in six.iteritems(kwargs): + if value: + params[key] = value + if resource_name is None: url = '/stacks/%s/events' % stack_id else: stack_id = self._resolve_stack_id(stack_id) url = '/stacks/%s/resources/%s/events' % ( - parse.quote(stack_id, ''), - parse.quote(strutils.safe_encode(resource_name), '')) - return self._list(url, "events") + parse.quote(stack_id, ''), + parse.quote(strutils.safe_encode(resource_name), '')) + if params: + url += '?%s' % parse.urlencode(params, True) + + return self._list(url, 'events') def get(self, stack_id, resource_name, event_id): """Get the details for a specific event. |