1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
"""Models for Supervisor jobs."""
from __future__ import annotations
from dataclasses import dataclass
from datetime import datetime # noqa: TCH003
from enum import StrEnum
from typing import Any
from uuid import UUID # noqa: TCH003
from .base import Request, ResponseData
# --- ENUMS ----
class JobCondition(StrEnum):
"""JobCondition type.
This is an incomplete list. Supervisor regularly adds support for new
job conditions as they are found to be needed. Therefore when returning
a list of job conditions, there may be some which are not in
this list parsed as strings on older versions of the client.
"""
AUTO_UPDATE = "auto_update"
FREE_SPACE = "free_space"
FROZEN = "frozen"
HAOS = "haos"
HEALTHY = "healthy"
HOST_NETWORK = "host_network"
INTERNET_HOST = "internet_host"
INTERNET_SYSTEM = "internet_system"
MOUNT_AVAILABLE = "mount_available"
OS_AGENT = "os_agent"
PLUGINS_UPDATED = "plugins_updated"
RUNNING = "running"
SUPERVISOR_UPDATED = "supervisor_updated"
# --- OBJECTS ----
@dataclass(slots=True, frozen=True)
class JobError(ResponseData):
"""JobError model."""
type: str
message: str
stage: str | None
@dataclass(slots=True, frozen=True)
class Job(ResponseData):
"""Job model."""
name: str | None
reference: str | None
uuid: UUID
progress: float
stage: str | None
done: bool | None
errors: list[JobError]
created: datetime
child_jobs: list[Job]
extra: dict[str, Any] | None
@dataclass(slots=True, frozen=True)
class JobsInfo(ResponseData):
"""JobsInfo model."""
ignore_conditions: list[JobCondition | str]
jobs: list[Job]
@dataclass(slots=True, frozen=True)
class JobsOptions(Request):
"""JobsOptions model."""
# We only do `| str` in responses since we can't control what supervisor returns
# Support for ignoring new job conditions will wait for a new version of library
ignore_conditions: list[JobCondition]
|