"""API client methods for loop directives."""

from __future__ import annotations

from typing import Any

from peon_mcp.common.base_client import BaseAPIClient


class DirectiveClient(BaseAPIClient):
    """Loop directive API client methods."""

    async def get_directives(
        self,
        loop_id: str,
        status: str | None = None,
    ) -> list[dict] | str:
        params: dict[str, Any] = {}
        if status is not None:
            params["status"] = status
        return await self._request(
            "GET", f"/api/loops/{loop_id}/directives", params=params,
        )

    async def create_directive(
        self,
        loop_id: str,
        data: dict[str, Any],
    ) -> dict | str:
        return await self._request(
            "POST", f"/api/loops/{loop_id}/directives", json=data,
        )

    async def update_directive(
        self,
        directive_id: str,
        data: dict[str, Any],
    ) -> dict | str:
        return await self._request(
            "PATCH", f"/api/directives/{directive_id}", json=data,
        )
