"""Healthchecks Resource."""

from typing import Any, Dict, Generator

from netorca_sdk.v2.base import BaseResource
from netorca_sdk.v2.models.healthcheck import Healthcheck


class HealthchecksResource(BaseResource):
    """Healthchecks resource."""

    endpoint = "healthchecks"
    model_class = Healthcheck

    def trigger_service_item(self, service_item_id: int) -> Dict[str, Any]:
        """
        Trigger healthcheck for a service item.

        Args:
            service_item_id: Service item ID

        Returns:
            Trigger response
        """
        return self.client.get_one(
            self.endpoint,
            service_item_id,
            custom_path=f"healthchecks/trigger/service_item/{service_item_id}"
        )

    def trigger_service(self, service_id: int) -> Dict[str, Any]:
        """
        Trigger healthcheck for a service.

        Args:
            service_id: Service ID

        Returns:
            Trigger response
        """
        return self.client.get_one(
            self.endpoint,
            service_id,
            custom_path=f"healthchecks/trigger/service/{service_id}"
        )

    def list(self, **filters: Any) -> Generator[Healthcheck, None, None]:
        """List healthchecks."""
        # Healthchecks might not support listing, but included for completeness
        return super().list(**filters)

    def update(self, id: int, data: Dict[str, Any], partial: bool = True) -> Healthcheck:
        """Healthchecks cannot be updated."""
        raise NotImplementedError("Healthchecks cannot be updated")

    def delete(self, id: int) -> None:
        """Healthchecks cannot be deleted."""
        raise NotImplementedError("Healthchecks cannot be deleted")
