Skip to content

Commit

Permalink
kernelci.cli: enable pagination arguments for kci user find
Browse files Browse the repository at this point in the history
Enable user to provide pagination arguments like `page_length`
and `page_number` for `kci user find` command.

Signed-off-by: Jeny Sadadia <[email protected]>
  • Loading branch information
Jeny Sadadia authored and JenySadadia committed Jan 15, 2024
1 parent 9fb39f4 commit a731d29
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions kernelci/cli/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
catch_error,
echo_json,
get_api,
get_pagination,
kci,
split_attributes,
)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a731d29

Please sign in to comment.