Publish curated Unraid-AppOps-Gateway source from ba66029223865607deddc234e283c11127324eb8
This commit is contained in:
1 parent
820244dbb3
commit
8dd4b40252
52 files changed
+11814
-288
No files matched your search
@@ -0,0 +1,48 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, model_validator
|
||||
|
||||
_JOB = re.compile(r"^forge-install-[0-9a-f]{64}$")
|
||||
_SAFE_CODE = re.compile(r"^[a-z][a-z0-9_]{0,95}$")
|
||||
|
||||
|
||||
class ForgeRouteStageResultV1(BaseModel):
|
||||
"""Safe public projection for the disabled-only Forge route staging operation."""
|
||||
|
||||
model_config = ConfigDict(
|
||||
extra="forbid",
|
||||
frozen=True,
|
||||
populate_by_name=True,
|
||||
strict=True,
|
||||
)
|
||||
|
||||
success: StrictBool
|
||||
status: Literal[
|
||||
"host_staged_disabled",
|
||||
"blocked",
|
||||
"conflict",
|
||||
"failed",
|
||||
"outcome_unknown",
|
||||
"not_found",
|
||||
]
|
||||
message: StrictStr = Field(pattern=_SAFE_CODE.pattern)
|
||||
target: Literal["itworx-forge"]
|
||||
job_id: StrictStr = Field(alias="jobId", pattern=_JOB.pattern)
|
||||
hostname: Literal["forge.example.com"]
|
||||
upstream: Literal["http://itworx-forge:8080"]
|
||||
route_state: Literal["host_staged_disabled", "not_routed"] = Field(alias="routeState")
|
||||
routed: StrictBool
|
||||
|
||||
@model_validator(mode="after")
|
||||
def state_is_disabled_only(self) -> ForgeRouteStageResultV1:
|
||||
staged = self.status == "host_staged_disabled"
|
||||
if (
|
||||
self.success is not staged
|
||||
or self.route_state != ("host_staged_disabled" if staged else "not_routed")
|
||||
or self.routed is not False
|
||||
):
|
||||
raise ValueError("Forge route stage results never activate a route")
|
||||
return self
|
||||
Reference in new issue
Block a user