From a731d2999ddf20a31d54324dbd816c4c7976ccee Mon Sep 17 00:00:00 2001 From: Jeny Sadadia Date: Tue, 26 Dec 2023 14:28:06 +0530 Subject: [PATCH] kernelci.cli: enable pagination arguments for `kci user find` Enable user to provide pagination arguments like `page_length` and `page_number` for `kci user find` command. Signed-off-by: Jeny Sadadia --- kernelci/cli/user.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kernelci/cli/user.py b/kernelci/cli/user.py index 9d396d1aa8..f2b1cef517 100644 --- a/kernelci/cli/user.py +++ b/kernelci/cli/user.py @@ -17,6 +17,7 @@ catch_error, echo_json, get_api, + get_pagination, kci, split_attributes, ) @@ -44,12 +45,16 @@ def whoami(config, api, indent, secrets): @Args.config @Args.api @Args.indent +@Args.page_length +@Args.page_number @catch_error -def find(attributes, config, api, indent, secrets): +# pylint: disable=too-many-arguments +def find(attributes, config, api, indent, secrets, page_length, page_number): """Find user profiles with arbitrary attributes""" api = get_api(config, api, secrets) + offset, limit = get_pagination(page_length, page_number) attributes = split_attributes(attributes) - users = api.user.find(attributes) + users = api.user.find(attributes, offset, limit) data = json.dumps(users, indent=indent or None) echo = click.echo_via_pager if len(users) > 1 else click.echo echo(data)