zabgrab.cli.app¶
Shared CLI state and central error handling.
- zabgrab.cli.app.pass_app¶
Decorator passing the
AppContextto a command.- Type:
callable
- zabgrab.cli.app.GLOBAL_OPTIONS¶
The options every command accepts (see
global_options()).- Type:
Functions
|
Add the global options to a command or group. |
|
Create a client that talks to a real server over HTTP(S). |
Classes
State shared by all commands: the click context object. |
|
|
Options accepted by every command (see |
|
Command group that turns exceptions into user-friendly messages. |
- zabgrab.cli.app.http_client(config)[source]¶
Create a client that talks to a real server over HTTP(S).
- Parameters:
config (ServerConfig) – The server’s URL and connection settings.
- Returns:
ZabbixClient – The client, not yet logged in.
- Return type:
- class zabgrab.cli.app.GlobalOptions(verbosity=0, debug=False, color=None, config_path=None, isolated=False, no_input=False)[source]¶
Bases:
objectOptions accepted by every command (see
global_options()).- Parameters:
- config_path¶
--config.- Type:
Path or None
- class zabgrab.cli.app.AppContext[source]¶
Bases:
objectState shared by all commands: the click context object.
Global options update
optionswhile the command line is parsed, at whichever level they appear; everything else is built on first use. Tests replace the adapters (secrets, client factory, clock, …) with fakes.- options¶
The global options.
- Type:
- env¶
The environment variables and platform paths.
- Type:
- secrets¶
Stores API tokens.
- Type:
- client_factory¶
Creates Zabbix clients.
- Type:
- layers()[source]¶
Find the config layers, including those without a file.
- Returns:
list of ConfigLayer – The layers, lowest priority first.
- Return type:
- config()[source]¶
Get the merged config, loaded on first use.
Interactive sessions are offered the chance to fix invalid files.
- Returns:
LoadedConfig – The config and the layers it came from.
- Raises:
ZabgrabError – If a config file is invalid and isn’t fixed.
- Return type:
- select_server(configured)[source]¶
Choose the server to use.
See
zabgrab.services.servers.select_server(). Custom servers entered at a prompt can be saved to the user config.
- update_server_url(name, url)[source]¶
Change a configured server’s URL in the config file that defines it.
- async connect(server)[source]¶
Connect and log in to a server.
- Parameters:
server (Server) – The server.
- Returns:
ZabbixClient – The logged-in client, to be closed after use.
- Raises:
ZabgrabError – If the server can’t be reached or logging in fails.
- Return type:
- zabgrab.cli.app.global_options(function)[source]¶
Add the global options to a command or group.
Every command gets them, so they can be given at any level, e.g. both
zabgrab -v hostsandzabgrab hosts -v.- Parameters:
function (callable) – The command or group’s function.
- Returns:
callable – The function, with the options added.
- Return type:
F
- class zabgrab.cli.app.ZabgrabGroup(name=None, commands=None, invoke_without_command=False, no_args_is_help=None, subcommand_metavar=None, chain=False, result_callback=None, **kwargs)[source]¶
Bases:
GroupCommand group that turns exceptions into user-friendly messages.
- Parameters:
- invoke(ctx)[source]¶
Run the command, reporting errors and exiting with their exit codes.
- Parameters:
ctx (click.Context) – The group’s context.
- Returns:
Any – What the command returns.
- Return type: