Source code for taimoe.platform.resources.runtimes
"""Runtimes resource for Taimoe Platform SDK."""
from __future__ import annotations
from datetime import datetime
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from taimoe.platform.client.client import TaimoeClient
from taimoe.platform.types.sync import RuntimeSyncResponse
[docs]
class RuntimesResource:
"""Resource for interacting with /api/v1/runtimes endpoints."""
def __init__(self, client: TaimoeClient) -> None:
self._client = client
[docs]
def sync_agents(
self,
runtime_id: str,
*,
since: datetime | None = None,
) -> RuntimeSyncResponse:
"""Synchronously pull agent configurations for this runtime."""
params = self._sync_params(since)
response = self._client._request("GET", f"/api/v1/runtimes/{runtime_id}/agents/sync", params=params)
return RuntimeSyncResponse.model_validate(response)
[docs]
async def sync_agents_async(
self,
runtime_id: str,
*,
since: datetime | None = None,
) -> RuntimeSyncResponse:
"""Asynchronously pull agent configurations for this runtime."""
params = self._sync_params(since)
response = await self._client._request_async("GET", f"/api/v1/runtimes/{runtime_id}/agents/sync", params=params)
return RuntimeSyncResponse.model_validate(response)
def _sync_params(self, since: datetime | None) -> dict[str, Any]:
if since is None:
return {}
return {"since": since.isoformat()}