feat(cloud): add targeted task governance foundation
Tests / Test passed: 659

This commit is contained in:
2026-07-13 22:21:12 +08:00
parent a3ba94be04
commit 2cd314b183
41 changed files with 2099 additions and 15 deletions
+32 -1
View File
@@ -72,15 +72,24 @@ class CloudClient:
workflow_definition_id: str | None = None,
driver_type: str | None = None,
capability_tags: list[str] | None = None,
target_host_id: str | None = None,
target_device_id: str | None = None,
) -> dict[str, Any]:
payload: dict[str, Any] = {
"goal": goal,
"workflow_definition_id": workflow_definition_id,
}
if driver_type is not None or capability_tags is not None:
if (
driver_type is not None
or capability_tags is not None
or target_host_id is not None
or target_device_id is not None
):
payload["constraints"] = {
"driver_type": driver_type,
"capability_tags": list(capability_tags or []),
"target_host_id": target_host_id,
"target_device_id": target_device_id,
}
resp = self._request("POST", "/tasks", json=payload)
return resp.json()
@@ -209,6 +218,28 @@ class CloudClient:
def revoke_user_sessions(self, user_id: str) -> None:
self._request("DELETE", f"/users/{user_id}/sessions")
# ------------------------------------------------------------- governance
def get_user_submission_policy(self, user_id: str) -> dict[str, Any]:
return self._request("GET", f"/users/{user_id}/submission-policy").json()
def update_user_submission_policy(
self, user_id: str, **policy: Any
) -> dict[str, Any]:
return self._request(
"PUT", f"/users/{user_id}/submission-policy", json=policy
).json()
def get_host_governance_policy(self, host_id: str) -> dict[str, Any]:
return self._request("GET", f"/hosts/{host_id}/governance-policy").json()
def update_host_governance_policy(
self, host_id: str, **policy: Any
) -> dict[str, Any]:
return self._request(
"PUT", f"/hosts/{host_id}/governance-policy", json=policy
).json()
# ------------------------------------------------------------------ helpers
def _url(self, path: str) -> str: