This commit is contained in:
@@ -14,6 +14,7 @@ from cloud.internal_api.models import (
|
||||
DeviceSnapshotModel,
|
||||
HeartbeatResponse,
|
||||
HostEnrollmentResponse,
|
||||
HostTaskSubmissionResponse,
|
||||
LeaseRenewalResponse,
|
||||
TerminalResultResponse,
|
||||
)
|
||||
@@ -146,6 +147,7 @@ class HostAgentClient:
|
||||
devices: list[DeviceSnapshotModel],
|
||||
*,
|
||||
address: str | None = None,
|
||||
policy_revision: int = 0,
|
||||
) -> HeartbeatResponse:
|
||||
response = await self._request(
|
||||
"PUT",
|
||||
@@ -154,10 +156,28 @@ class HostAgentClient:
|
||||
"host_id": self.config.host_id,
|
||||
"address": address,
|
||||
"devices": [device.model_dump(mode="json") for device in devices],
|
||||
"policy_revision": policy_revision,
|
||||
},
|
||||
)
|
||||
return HeartbeatResponse.model_validate(response.json())
|
||||
|
||||
async def submit_self_task(
|
||||
self,
|
||||
*,
|
||||
goal: str,
|
||||
device_id: str | None = None,
|
||||
) -> HostTaskSubmissionResponse:
|
||||
response = await self._request(
|
||||
"POST",
|
||||
f"/internal/v1/hosts/{self.config.host_id}/tasks",
|
||||
json={
|
||||
"host_id": self.config.host_id,
|
||||
"goal": goal,
|
||||
"device_id": device_id,
|
||||
},
|
||||
)
|
||||
return HostTaskSubmissionResponse.model_validate(response.json())
|
||||
|
||||
async def claim(self) -> AssignmentModel | None:
|
||||
response = await self._request(
|
||||
"POST",
|
||||
|
||||
Reference in New Issue
Block a user