Skip to content

Commit d418a11

Browse files
Add deployment pagination
1 parent 29dbddd commit d418a11

2 files changed

Lines changed: 32 additions & 3 deletions

File tree

coriolisclient/cli/deployments.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,23 @@ class ListDeployment(lister.Lister):
273273

274274
def get_parser(self, prog_name):
275275
parser = super(ListDeployment, self).get_parser(prog_name)
276+
parser.add_argument(
277+
'--marker',
278+
help='The id of the last retrieved execution.')
279+
parser.add_argument(
280+
'--limit', type=int,
281+
help='Maximum number of executions to retrieve.')
282+
parser.add_argument(
283+
'--sort',
284+
help='Comma-separated list of sort keys and directions in the form '
285+
'of <key>[:<asc|desc>]. The direction defaults to descending if '
286+
'not specified.')
276287
return parser
277288

278289
def take_action(self, args):
279-
obj_list = self.app.client_manager.coriolis.deployments.list()
290+
obj_list = self.app.client_manager.coriolis.deployments.list(
291+
marker=args.marker,
292+
limit=args.limit,
293+
sort_keys=sort_keys,
294+
sort_dirs=sort_dirs)
280295
return DeploymentFormatter().list_objects(obj_list)

coriolisclient/v1/deployments.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,25 @@ class DeploymentManager(base.BaseManager):
5252
def __init__(self, api):
5353
super(DeploymentManager, self).__init__(api)
5454

55-
def list(self, detail=False):
55+
def list(self, detail=False,
56+
marker=None, limit=None,
57+
sort_keys=None, sort_dirs=None):
58+
query = []
59+
if marker is not None:
60+
query.append(("marker", marker))
61+
if limit is not None:
62+
query.append(("limit", limit))
63+
if sort_keys is not None:
64+
query.extend(('sort_key', sort_key)
65+
for sort_key in sort_keys)
66+
if sort_dirs is not None:
67+
query.extend(('sort_dir', sort_dir)
68+
for sort_dir in sort_dirs)
69+
5670
path = "/deployments"
5771
if detail:
5872
path = "%s/detail" % path
59-
return self._list(path, 'deployments')
73+
return self._list(path, 'deployments', query=query)
6074

6175
def get(self, deployment):
6276
return self._get(

0 commit comments

Comments
 (0)