Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kci-dev/results: Add limit and offset to nodes list #22

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions kci-dev/subcommands/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def get_node(url, nodeid):
click.secho(pprint.pprint(response.text), fg="green")


def get_nodes(url):
def get_nodes(url, limit, offset):
headers = {
"Content-Type": "application/json; charset=utf-8",
}
url = url + "/nodes"
url = url + "/nodes?limit=" + str(limit) + "&offset=" + str(offset)
click.secho(url)
response = requests.get(url, headers=headers)
click.secho(response.status_code, fg="green")
Expand All @@ -51,18 +51,31 @@ def get_nodes(url):
)
@click.option(
"--nodes",
is_flag=True,
required=False,
help="Get last nodes results",
)
@click.option(
"--limit",
default=50,
required=False,
help="Pagination limit for nodes",
)
@click.option(
"--offset",
default=0,
required=False,
help="Offset of the pagination",
)
@click.pass_context
def results(ctx, nodeid, nodes):
def results(ctx, nodeid, nodes, limit, offset):
config = ctx.obj.get("CFG")
instance = ctx.obj.get("INSTANCE")
url = api_connection(config[instance]["host"])
if nodeid:
get_node(url, nodeid)
if nodes:
get_nodes(url)
get_nodes(url, limit, offset)


if __name__ == "__main__":
Expand Down
Loading