"""
Alerts API namespace.

AUTO-GENERATED by scripts/generate_sdk.py - DO NOT EDIT MANUALLY!
Regenerate with: python scripts/generate_sdk.py --category alerts
"""
from __future__ import annotations

from typing import Any, Dict, Optional

from ._base import AsyncBaseAPI, BaseAPI


class AlertsAPI(BaseAPI):
    """Alerts namespace: ack, create, delete, evaluate, get, history, list, run, update."""

    def ack(
        self,
        *,
        event_id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Acknowledge alert

        Args:
        event_id: Event ID"""
        params: Dict[str, Any] = {}
        params["event_id"] = event_id
        return self._call("alerts.ack", params=params, options=options, context=context)

    def create(
        self,
        *,
        name: str,
        condition: Dict[str, Any],
        action: Optional[Dict[str, Any]] = None,
        enabled: Optional[bool] = True,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Create alert rule

        Args:
        name: Alert name
        condition: Alert condition
        action: Alert action (webhook, email)
        enabled: Enable alert"""
        params: Dict[str, Any] = {}
        params["name"] = name
        params["condition"] = condition
        if action is not None:
            params["action"] = action
        if enabled is not None:
            params["enabled"] = enabled
        return self._call("alerts.create", params=params, options=options, context=context)

    def delete(
        self,
        *,
        rule_id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Delete alert rule

        Args:
        rule_id: Rule ID"""
        params: Dict[str, Any] = {}
        params["rule_id"] = rule_id
        return self._call("alerts.delete", params=params, options=options, context=context)

    def evaluate(
        self,
        *,
        rule_id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Evaluate alert

        Manually evaluate an alert rule.

        Args:
        rule_id: Rule ID"""
        params: Dict[str, Any] = {}
        params["rule_id"] = rule_id
        return self._call("alerts.evaluate", params=params, options=options, context=context)

    def get(
        self,
        *,
        rule_id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Get alert rule

        Args:
        rule_id: Rule ID"""
        params: Dict[str, Any] = {}
        params["rule_id"] = rule_id
        return self._call("alerts.get", params=params, options=options, context=context)

    def history(
        self,
        *,
        rule_id: Optional[str] = None,
        limit: Optional[int] = 100,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """Alert history

        Get alert event history.

        Args:
        rule_id: Filter by rule
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        if rule_id is not None:
            params["rule_id"] = rule_id
        if limit is not None:
            params["limit"] = limit
        return self._call("alerts.history", params=params, options=options, context=context, response_format=response_format)

    def list(
        self,
        *,
        enabled: Optional[bool] = None,
        limit: Optional[int] = 100,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """List alert rules

        Args:
        enabled: Filter by enabled
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        if enabled is not None:
            params["enabled"] = enabled
        if limit is not None:
            params["limit"] = limit
        return self._call("alerts.list", params=params, options=options, context=context, response_format=response_format)

    def run(
        self,
        *,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Run all alerts

        Evaluate all enabled alerts."""
        params: Dict[str, Any] = {}
        return self._call("alerts.run", params=params, options=options, context=context)

    def update(
        self,
        *,
        rule_id: str,
        name: Optional[str] = None,
        condition: Optional[Dict[str, Any]] = None,
        action: Optional[Dict[str, Any]] = None,
        enabled: Optional[bool] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Update alert rule

        Args:
        rule_id: Rule ID
        name: New name
        condition: New condition
        action: New action
        enabled: Enable/disable"""
        params: Dict[str, Any] = {}
        params["rule_id"] = rule_id
        if name is not None:
            params["name"] = name
        if condition is not None:
            params["condition"] = condition
        if action is not None:
            params["action"] = action
        if enabled is not None:
            params["enabled"] = enabled
        return self._call("alerts.update", params=params, options=options, context=context)



class AsyncAlertsAPI(AsyncBaseAPI):
    """Alerts namespace: ack, create, delete, evaluate, get, history, list, run, update."""

    async def ack(
        self,
        *,
        event_id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Acknowledge alert

        Args:
        event_id: Event ID"""
        params: Dict[str, Any] = {}
        params["event_id"] = event_id
        return await self._call("alerts.ack", params=params, options=options, context=context)

    async def create(
        self,
        *,
        name: str,
        condition: Dict[str, Any],
        action: Optional[Dict[str, Any]] = None,
        enabled: Optional[bool] = True,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Create alert rule

        Args:
        name: Alert name
        condition: Alert condition
        action: Alert action (webhook, email)
        enabled: Enable alert"""
        params: Dict[str, Any] = {}
        params["name"] = name
        params["condition"] = condition
        if action is not None:
            params["action"] = action
        if enabled is not None:
            params["enabled"] = enabled
        return await self._call("alerts.create", params=params, options=options, context=context)

    async def delete(
        self,
        *,
        rule_id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Delete alert rule

        Args:
        rule_id: Rule ID"""
        params: Dict[str, Any] = {}
        params["rule_id"] = rule_id
        return await self._call("alerts.delete", params=params, options=options, context=context)

    async def evaluate(
        self,
        *,
        rule_id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Evaluate alert

        Manually evaluate an alert rule.

        Args:
        rule_id: Rule ID"""
        params: Dict[str, Any] = {}
        params["rule_id"] = rule_id
        return await self._call("alerts.evaluate", params=params, options=options, context=context)

    async def get(
        self,
        *,
        rule_id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Get alert rule

        Args:
        rule_id: Rule ID"""
        params: Dict[str, Any] = {}
        params["rule_id"] = rule_id
        return await self._call("alerts.get", params=params, options=options, context=context)

    async def history(
        self,
        *,
        rule_id: Optional[str] = None,
        limit: Optional[int] = 100,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """Alert history

        Get alert event history.

        Args:
        rule_id: Filter by rule
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        if rule_id is not None:
            params["rule_id"] = rule_id
        if limit is not None:
            params["limit"] = limit
        return await self._call("alerts.history", params=params, options=options, context=context, response_format=response_format)

    async def list(
        self,
        *,
        enabled: Optional[bool] = None,
        limit: Optional[int] = 100,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """List alert rules

        Args:
        enabled: Filter by enabled
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        if enabled is not None:
            params["enabled"] = enabled
        if limit is not None:
            params["limit"] = limit
        return await self._call("alerts.list", params=params, options=options, context=context, response_format=response_format)

    async def run(
        self,
        *,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Run all alerts

        Evaluate all enabled alerts."""
        params: Dict[str, Any] = {}
        return await self._call("alerts.run", params=params, options=options, context=context)

    async def update(
        self,
        *,
        rule_id: str,
        name: Optional[str] = None,
        condition: Optional[Dict[str, Any]] = None,
        action: Optional[Dict[str, Any]] = None,
        enabled: Optional[bool] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Update alert rule

        Args:
        rule_id: Rule ID
        name: New name
        condition: New condition
        action: New action
        enabled: Enable/disable"""
        params: Dict[str, Any] = {}
        params["rule_id"] = rule_id
        if name is not None:
            params["name"] = name
        if condition is not None:
            params["condition"] = condition
        if action is not None:
            params["action"] = action
        if enabled is not None:
            params["enabled"] = enabled
        return await self._call("alerts.update", params=params, options=options, context=context)


