Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kernelci.cli: use get_pagination() in kci node
Browse files Browse the repository at this point in the history
Update `kci node find` implementation to use get_pagination() with the
standard command line page options.

Signed-off-by: Guillaume Tucker <gtucker@gtucker.io>
gctucker committed Dec 11, 2023
1 parent 318b997 commit 7085a8e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions kernelci/cli/node.py
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
from . import (
Args,
get_api,
get_pagination,
kci,
split_attributes,
)
@@ -38,18 +39,16 @@ def get(node_id, config, api, indent):

@kci_node.command
@click.argument('attributes', nargs=-1)
@click.option('--offset', help="Offset for paginated results")
@click.option('--limit',
help="Maximum number of results to retrieve."
"When set to 0, no limit is used and all the "
"matching results are retrieved.")
@Args.config
@Args.api
@Args.indent
def find(attributes, config, api, # pylint: disable=too-many-arguments
indent, offset, limit):
@Args.page_length
@Args.page_number
# pylint: disable=too-many-arguments
def find(attributes, config, api, indent, page_length, page_number):
"""Find nodes with arbitrary attributes"""
api = get_api(config, api)
offset, limit = get_pagination(page_length, page_number)
attributes = split_attributes(attributes)
nodes = api.get_nodes(attributes, offset, limit)
data = json.dumps(nodes, indent=indent)

0 comments on commit 7085a8e

Please sign in to comment.