infrahub_sdk.task.manager
Classes
InfraHubTaskManagerBase
InfrahubTaskManager
Methods:
count
count(self, filters: TaskFilter | None = None) -> int
Count the number of tasks.
Args:
filters: The filter to apply to the tasks. Defaults to None.
Returns:
- The number of tasks.
all
all(self, limit: int | None = None, offset: int | None = None, timeout: int | None = None, parallel: bool = False, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task]
Get all tasks.
Args:
limit: The maximum number of tasks to return. Defaults to None.offset: The offset to start the tasks from. Defaults to None.timeout: The timeout to wait for the tasks to complete. Defaults to None.parallel: Whether to query the tasks in parallel. Defaults to False.include_logs: Whether to include the logs in the tasks. Defaults to False.include_related_nodes: Whether to include the related nodes in the tasks. Defaults to False.
Returns:
- A list of tasks.
filter
filter(self, filter: TaskFilter | None = None, limit: int | None = None, offset: int | None = None, timeout: int | None = None, parallel: bool = False, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task]
Filter tasks.
Args:
filter: The filter to apply to the tasks. Defaults to None.limit: The maximum number of tasks to return. Defaults to None.offset: The offset to start the tasks from. Defaults to None.timeout: The timeout to wait for the tasks to complete. Defaults to None.parallel: Whether to query the tasks in parallel. Defaults to False.include_logs: Whether to include the logs in the tasks. Defaults to False.include_related_nodes: Whether to include the related nodes in the tasks. Defaults to False.
Returns:
- A list of tasks.
get
get(self, id: str, include_logs: bool = False, include_related_nodes: bool = False) -> Task
wait_for_completion
wait_for_completion(self, id: str, interval: int = 1, timeout: int = 60) -> Task
Wait for a task to complete.
Args:
id: The id of the task to wait for.interval: The interval to check the task state. Defaults to 1.timeout: The timeout to wait for the task to complete. Defaults to 60.
Raises:
TaskNotCompletedError: The task did not complete in the given timeout.
Returns:
- The task object.
process_page
process_page(client: InfrahubClient, query: Query, page_number: int, timeout: int | None = None) -> tuple[list[Task], int | None]
Process a single page of results.
Args:
client: The client to use to execute the query.query: The query to execute.page_number: The page number to process.timeout: The timeout to wait for the query to complete. Defaults to None.
Returns:
- A tuple containing a list of tasks and the count of tasks.
process_batch
process_batch(self, filters: TaskFilter | None = None, timeout: int | None = None, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task]
Process queries in parallel mode.
process_non_batch
process_non_batch(self, filters: TaskFilter | None = None, offset: int | None = None, limit: int | None = None, timeout: int | None = None, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task]
Process queries without parallel mode.
InfrahubTaskManagerSync
Methods:
count
count(self, filters: TaskFilter | None = None) -> int
Count the number of tasks.
Args:
filters: The filter to apply to the tasks. Defaults to None.
Returns:
- The number of tasks.
all
all(self, limit: int | None = None, offset: int | None = None, timeout: int | None = None, parallel: bool = False, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task]
Get all tasks.
Args:
limit: The maximum number of tasks to return. Defaults to None.offset: The offset to start the tasks from. Defaults to None.timeout: The timeout to wait for the tasks to complete. Defaults to None.parallel: Whether to query the tasks in parallel. Defaults to False.include_logs: Whether to include the logs in the tasks. Defaults to False.include_related_nodes: Whether to include the related nodes in the tasks. Defaults to False.
Returns:
- A list of tasks.
filter
filter(self, filter: TaskFilter | None = None, limit: int | None = None, offset: int | None = None, timeout: int | None = None, parallel: bool = False, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task]
Filter tasks.
Args:
filter: The filter to apply to the tasks. Defaults to None.limit: The maximum number of tasks to return. Defaults to None.offset: The offset to start the tasks from. Defaults to None.timeout: The timeout to wait for the tasks to complete. Defaults to None.parallel: Whether to query the tasks in parallel. Defaults to False.include_logs: Whether to include the logs in the tasks. Defaults to False.include_related_nodes: Whether to include the related nodes in the tasks. Defaults to False.
Returns:
- A list of tasks.
get
get(self, id: str, include_logs: bool = False, include_related_nodes: bool = False) -> Task
wait_for_completion
wait_for_completion(self, id: str, interval: int = 1, timeout: int = 60) -> Task
Wait for a task to complete.
Args:
id: The id of the task to wait for.interval: The interval to check the task state. Defaults to 1.timeout: The timeout to wait for the task to complete. Defaults to 60.
Raises:
TaskNotCompletedError: The task did not complete in the given timeout.
Returns:
- The task object.
process_page
process_page(client: InfrahubClientSync, query: Query, page_number: int, timeout: int | None = None) -> tuple[list[Task], int | None]
Process a single page of results.
Args:
client: The client to use to execute the query.query: The query to execute.page_number: The page number to process.timeout: The timeout to wait for the query to complete. Defaults to None.
Returns:
- A tuple containing a list of tasks and the count of tasks.
process_batch
process_batch(self, filters: TaskFilter | None = None, timeout: int | None = None, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task]
Process queries in parallel mode.
process_non_batch
process_non_batch(self, filters: TaskFilter | None = None, offset: int | None = None, limit: int | None = None, timeout: int | None = None, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task]
Process queries without parallel mode.