From 353ba5f8c862edcd1a591f6657c042b37cf5434b Mon Sep 17 00:00:00 2001 From: wangxiyuan Date: Fri, 29 Jan 2016 14:14:04 +0800 Subject: [PATCH] Don't return links if subscriptions are empty If there is no subscription in a queue, it will return links like: "/v2/queues/{queue_name}/subscriptions?marker=" which is useless. It should keep the same with queue, pools and flavors. APIImpact Change-Id: I08dd0f675bcd25cd63e17a0aa9779895bd401e32 --- zaqar/transport/wsgi/v2_0/subscriptions.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/zaqar/transport/wsgi/v2_0/subscriptions.py b/zaqar/transport/wsgi/v2_0/subscriptions.py index 2502d14fc..85b859755 100644 --- a/zaqar/transport/wsgi/v2_0/subscriptions.py +++ b/zaqar/transport/wsgi/v2_0/subscriptions.py @@ -141,14 +141,17 @@ class CollectionResource(object): # Got some. Prepare the response. kwargs['marker'] = next(results) or kwargs.get('marker', '') - response_body = { - 'subscriptions': subscriptions, - 'links': [ + links = [] + if results: + links = [ { 'rel': 'next', 'href': req.path + falcon.to_query_str(kwargs) } ] + response_body = { + 'subscriptions': subscriptions, + 'links': links } resp.body = utils.to_json(response_body)