Support query queues with count

Zaqar will support query queues with '--with_count' to
return the amount of the queues. This will help users to
quickly get the exact total number of queues which they own.

Change-Id: Iced54e7d270e389a23db2a19394025710565923d
Implements: blueprint query-queues-with-count
Signed-off-by: wanghao <sxmatch1986@gmail.com>
This commit is contained in:
wanghao 2020-02-12 10:08:01 +08:00
parent 2cc0d00205
commit 6e9a5b59fe
2 changed files with 49 additions and 2 deletions

View File

@ -0,0 +1,5 @@
---
features:
- Support query queues with filter 'with_count=true' to return the amount of
the queues. This will help users to quickly get the exact total number of
queues which they own.

View File

@ -48,9 +48,51 @@ class OldDeleteQueue(cli.OldDeleteQueue):
pass pass
class ListQueues(cli.ListQueues): class ListQueues(command.Lister):
"""List available queues""" """List available queues"""
pass
_description = _("List available queues")
log = logging.getLogger(__name__ + ".ListQueues")
def get_parser(self, prog_name):
parser = super(ListQueues, self).get_parser(prog_name)
parser.add_argument(
"--marker",
metavar="<queue_id>",
help="Queue's paging marker")
parser.add_argument(
"--limit",
metavar="<limit>",
help="Page size limit")
parser.add_argument(
"--detailed",
action="store_true",
help="If show detailed information of queue")
parser.add_argument(
"--with_count",
action="store_true",
help="If show amount information of queue")
return parser
def take_action(self, parsed_args):
client = _get_client(self, parsed_args)
kwargs = {}
columns = ["Name"]
if parsed_args.marker is not None:
kwargs["marker"] = parsed_args.marker
if parsed_args.limit is not None:
kwargs["limit"] = parsed_args.limit
if parsed_args.detailed is not None and parsed_args.detailed:
kwargs["detailed"] = parsed_args.detailed
columns.extend(["Metadata_Dict", "Href"])
if parsed_args.with_count is not None and parsed_args.with_count:
kwargs["with_count"] = parsed_args.with_count
columns.extend(["Count"])
data = client.queues(**kwargs)
columns = tuple(columns)
return (columns, (utils.get_item_properties(s, columns) for s in data))
class OldListQueues(cli.OldListQueues): class OldListQueues(cli.OldListQueues):