"""Routing presets — saved configs referenced as @preset/slug."""

from __future__ import annotations

from typing import Any, Dict, Optional

from .._resource import AsyncResource, Resource


class Presets(Resource):
    """Sync preset operations."""

    def list(self) -> Dict[str, Any]:
        """List all presets."""
        return self._get("/v1/presets")

    def get(self, slug: str) -> Dict[str, Any]:
        """Get a preset by slug."""
        return self._get(f"/v1/presets/{slug}")

    def create(self, params: Dict[str, Any]) -> Dict[str, Any]:
        """Create a new preset."""
        return self._post("/v1/presets", params)

    def update(self, slug: str, params: Dict[str, Any]) -> Dict[str, Any]:
        """Update an existing preset."""
        return self._put(f"/v1/presets/{slug}", params)

    def remove(self, slug: str) -> Dict[str, Any]:
        """Delete a preset."""
        return self._delete(f"/v1/presets/{slug}")

    def simulate(self, slug: str) -> Dict[str, Any]:
        """Run a routing simulation with this preset."""
        return self._post(f"/v1/presets/{slug}/simulate")


class AsyncPresets(AsyncResource):
    """Async preset operations."""

    async def list(self) -> Dict[str, Any]:
        return await self._get("/v1/presets")

    async def get(self, slug: str) -> Dict[str, Any]:
        return await self._get(f"/v1/presets/{slug}")

    async def create(self, params: Dict[str, Any]) -> Dict[str, Any]:
        return await self._post("/v1/presets", params)

    async def update(self, slug: str, params: Dict[str, Any]) -> Dict[str, Any]:
        return await self._put(f"/v1/presets/{slug}", params)

    async def remove(self, slug: str) -> Dict[str, Any]:
        return await self._delete(f"/v1/presets/{slug}")

    async def simulate(self, slug: str) -> Dict[str, Any]:
        return await self._post(f"/v1/presets/{slug}/simulate")
