zabgrab.services.collect

Working out which items to fetch: the server, the items, and download jobs.

zabgrab.services.collect.SelectServer

Picks the server for a query’s server reference (asking if needed).

Type:

type

zabgrab.services.collect.Connect

Returns a logged-in client for a server.

Type:

type

zabgrab.services.collect.PICKER_LIMIT

The most search results offered when picking items.

Type:

int

zabgrab.services.collect.ITEMS_FIX

How to give items without being asked.

Type:

str

Functions

collect(query, ui, *, select_server, connect)

Resolve the query's server and each request's items into download jobs.

pick_items(client, ui)

Ask the user to search for and pick items.

Classes

Plan([jobs, clients])

The items to fetch, and connections to their servers.

class zabgrab.services.collect.Plan(jobs=<factory>, clients=<factory>)[source]

Bases: object

The items to fetch, and connections to their servers.

Parameters:
jobs

One download job per item.

Type:

list of Job

clients

The logged-in connections (one, except when updating a group fetched from several servers before fetches used one).

Type:

dict of Server to ZabbixClient

async close()[source]

Close the connections.

Return type:

None

async zabgrab.services.collect.collect(query, ui, *, select_server, connect, yes=False)[source]

Resolve the query’s server and each request’s items into download jobs.

Items matched by several requests are fetched once. The connection is kept in the plan for downloading; close it when done. Answers given along the way (the server, items picked) are recorded in query.answers.

Parameters:
  • query (Query) – What to fetch.

  • ui (UI) – Asks for items when none are given, and about more than max_items.

  • select_server (callable) – Picks the server for the query’s server reference.

  • connect (callable) – Returns a logged-in client for a server.

  • yes (bool, optional) – Fetch however many items match (--yes).

Returns:

Plan – The jobs and the open connection.

Return type:

Plan

async zabgrab.services.collect.pick_items(client, ui)[source]

Ask the user to search for and pick items.

Parameters:
  • client (ZabbixClient) – The server to search.

  • ui (UI) – Asks for the search and the choice.

Returns:

  • list of Item – The items picked.

  • tuple of ItemSpec – Specs that select them: the search pattern if every match was picked, otherwise the picked items’ IDs.

Raises:

InputRequired – If the session isn’t interactive.

Return type:

tuple[list[Item], tuple[ItemSpec, …]]