Coverage for harbor_cli/commands/api/auditlog.py: 83%
12 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-02-09 12:09 +0100
« prev ^ index » next coverage.py v6.5.0, created at 2023-02-09 12:09 +0100
1from __future__ import annotations
3from typing import Optional
5import typer
7from ...output.render import render_result
8from ...state import state
9from ...utils.commands import inject_resource_options
11# Create a command group
12app = typer.Typer(name="auditlog", help="System information", no_args_is_help=True)
15@app.command("list")
16@inject_resource_options()
17def list_audit_logs(
18 ctx: typer.Context,
19 query: Optional[str],
20 sort: Optional[str],
21 page: int,
22 page_size: int,
23 limit: Optional[int],
24) -> None:
25 """List audit logs for projects the current user has access to.
26 [bold red]WARNING:[/] This command can return a lot of data if no query or limit
27 is specified. Use [bold]--retrieve-all[/] to fetch all pages.
28 """
29 logs = state.run(
30 state.client.get_audit_logs(
31 query=query,
32 sort=sort,
33 page=page,
34 page_size=page_size,
35 limit=limit,
36 ),
37 f"Fetching audit logs...",
38 )
39 render_result(logs, ctx)