"""
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,
        ack: Optional[str] = None,
        id: Optional[str] = None,
        note: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Acknowledge alert

        Args:
        event_id: Event ID"""
        _payload: Dict[str, Any] = {}
        _payload["event_id"] = event_id
        if ack is not None:
            _payload["ack"] = ack
        if id is not None:
            _payload["id"] = id
        if note is not None:
            _payload["note"] = note
        return self._call("alerts.ack", params=_payload, options=options, context=context)

    def create(
        self,
        *,
        name: str,
        config: Optional[Dict[str, Any]] = None,
        cooldown_seconds: Optional[str] = None,
        delivery: Optional[str] = None,
        description: Optional[str] = None,
        enabled: Optional[bool] = True,
        rule_type: Optional[str] = None,
        severity: Optional[str] = None,
        type_: Optional[str] = None,
        visibility: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Create alert rule

        Args:
        name: Alert name
        enabled: Enable alert"""
        _payload: Dict[str, Any] = {}
        _payload["name"] = name
        if config is not None:
            _payload["config"] = config
        if cooldown_seconds is not None:
            _payload["cooldown_seconds"] = cooldown_seconds
        if delivery is not None:
            _payload["delivery"] = delivery
        if description is not None:
            _payload["description"] = description
        if enabled is not None:
            _payload["enabled"] = enabled
        if rule_type is not None:
            _payload["rule_type"] = rule_type
        if severity is not None:
            _payload["severity"] = severity
        if type_ is not None:
            _payload["type"] = type_
        if visibility is not None:
            _payload["visibility"] = visibility
        return self._call("alerts.create", params=_payload, options=options, context=context)

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

        Args:
        rule_id: Rule ID"""
        _payload: Dict[str, Any] = {}
        _payload["rule_id"] = rule_id
        if delete_events is not None:
            _payload["delete_events"] = delete_events
        if id is not None:
            _payload["id"] = id
        if name is not None:
            _payload["name"] = name
        return self._call("alerts.delete", params=_payload, options=options, context=context)

    def evaluate(
        self,
        *,
        rule_id: str,
        id: Optional[str] = None,
        name: Optional[str] = None,
        update_stats: Optional[str] = None,
        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"""
        _payload: Dict[str, Any] = {}
        _payload["rule_id"] = rule_id
        if id is not None:
            _payload["id"] = id
        if name is not None:
            _payload["name"] = name
        if update_stats is not None:
            _payload["update_stats"] = update_stats
        return self._call("alerts.evaluate", params=_payload, options=options, context=context)

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

        Args:
        rule_id: Rule ID"""
        _payload: Dict[str, Any] = {}
        _payload["rule_id"] = rule_id
        if id is not None:
            _payload["id"] = id
        if name is not None:
            _payload["name"] = name
        return self._call("alerts.get", params=_payload, options=options, context=context)

    def history(
        self,
        *,
        ack: Optional[str] = None,
        id: Optional[str] = None,
        offset: Optional[int] = None,
        rule_id: Optional[str] = None,
        limit: Optional[int] = 100,
        status: Optional[str] = None,
        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"""
        _payload: Dict[str, Any] = {}
        if ack is not None:
            _payload["ack"] = ack
        if id is not None:
            _payload["id"] = id
        if offset is not None:
            _payload["offset"] = offset
        if rule_id is not None:
            _payload["rule_id"] = rule_id
        if limit is not None:
            _payload["limit"] = limit
        if status is not None:
            _payload["status"] = status
        return self._call("alerts.history", params=_payload, options=options, context=context, response_format=response_format)

    def list(
        self,
        *,
        enabled: Optional[bool] = None,
        limit: Optional[int] = 100,
        offset: Optional[int] = None,
        order: Optional[str] = None,
        rule_type: Optional[str] = None,
        search: Optional[str] = None,
        sort: Optional[str] = None,
        type_: Optional[str] = None,
        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"""
        _payload: Dict[str, Any] = {}
        if enabled is not None:
            _payload["enabled"] = enabled
        if limit is not None:
            _payload["limit"] = limit
        if offset is not None:
            _payload["offset"] = offset
        if order is not None:
            _payload["order"] = order
        if rule_type is not None:
            _payload["rule_type"] = rule_type
        if search is not None:
            _payload["search"] = search
        if sort is not None:
            _payload["sort"] = sort
        if type_ is not None:
            _payload["type"] = type_
        return self._call("alerts.list", params=_payload, options=options, context=context, response_format=response_format)

    def run(
        self,
        *,
        dry_run: Optional[str] = None,
        force: Optional[str] = None,
        id: Optional[str] = None,
        limit: Optional[int] = None,
        name: Optional[str] = None,
        rule_id: Optional[str] = None,
        rule_type: Optional[str] = None,
        type_: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Run all alerts

        Evaluate all enabled alerts."""
        _payload: Dict[str, Any] = {}
        if dry_run is not None:
            _payload["dry_run"] = dry_run
        if force is not None:
            _payload["force"] = force
        if id is not None:
            _payload["id"] = id
        if limit is not None:
            _payload["limit"] = limit
        if name is not None:
            _payload["name"] = name
        if rule_id is not None:
            _payload["rule_id"] = rule_id
        if rule_type is not None:
            _payload["rule_type"] = rule_type
        if type_ is not None:
            _payload["type"] = type_
        return self._call("alerts.run", params=_payload, options=options, context=context)

    def update(
        self,
        *,
        rule_id: str,
        config: Optional[Dict[str, Any]] = None,
        cooldown_seconds: Optional[str] = None,
        delivery: Optional[str] = None,
        description: Optional[str] = None,
        id: Optional[str] = None,
        new_name: Optional[str] = None,
        name: Optional[str] = None,
        enabled: Optional[bool] = None,
        rule_type: Optional[str] = None,
        severity: Optional[str] = None,
        type_: Optional[str] = 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
        enabled: Enable/disable"""
        _payload: Dict[str, Any] = {}
        _payload["rule_id"] = rule_id
        if config is not None:
            _payload["config"] = config
        if cooldown_seconds is not None:
            _payload["cooldown_seconds"] = cooldown_seconds
        if delivery is not None:
            _payload["delivery"] = delivery
        if description is not None:
            _payload["description"] = description
        if id is not None:
            _payload["id"] = id
        if new_name is not None:
            _payload["new_name"] = new_name
        if name is not None:
            _payload["name"] = name
        if enabled is not None:
            _payload["enabled"] = enabled
        if rule_type is not None:
            _payload["rule_type"] = rule_type
        if severity is not None:
            _payload["severity"] = severity
        if type_ is not None:
            _payload["type"] = type_
        return self._call("alerts.update", params=_payload, 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,
        ack: Optional[str] = None,
        id: Optional[str] = None,
        note: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Acknowledge alert

        Args:
        event_id: Event ID"""
        _payload: Dict[str, Any] = {}
        _payload["event_id"] = event_id
        if ack is not None:
            _payload["ack"] = ack
        if id is not None:
            _payload["id"] = id
        if note is not None:
            _payload["note"] = note
        return await self._call("alerts.ack", params=_payload, options=options, context=context)

    async def create(
        self,
        *,
        name: str,
        config: Optional[Dict[str, Any]] = None,
        cooldown_seconds: Optional[str] = None,
        delivery: Optional[str] = None,
        description: Optional[str] = None,
        enabled: Optional[bool] = True,
        rule_type: Optional[str] = None,
        severity: Optional[str] = None,
        type_: Optional[str] = None,
        visibility: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Create alert rule

        Args:
        name: Alert name
        enabled: Enable alert"""
        _payload: Dict[str, Any] = {}
        _payload["name"] = name
        if config is not None:
            _payload["config"] = config
        if cooldown_seconds is not None:
            _payload["cooldown_seconds"] = cooldown_seconds
        if delivery is not None:
            _payload["delivery"] = delivery
        if description is not None:
            _payload["description"] = description
        if enabled is not None:
            _payload["enabled"] = enabled
        if rule_type is not None:
            _payload["rule_type"] = rule_type
        if severity is not None:
            _payload["severity"] = severity
        if type_ is not None:
            _payload["type"] = type_
        if visibility is not None:
            _payload["visibility"] = visibility
        return await self._call("alerts.create", params=_payload, options=options, context=context)

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

        Args:
        rule_id: Rule ID"""
        _payload: Dict[str, Any] = {}
        _payload["rule_id"] = rule_id
        if delete_events is not None:
            _payload["delete_events"] = delete_events
        if id is not None:
            _payload["id"] = id
        if name is not None:
            _payload["name"] = name
        return await self._call("alerts.delete", params=_payload, options=options, context=context)

    async def evaluate(
        self,
        *,
        rule_id: str,
        id: Optional[str] = None,
        name: Optional[str] = None,
        update_stats: Optional[str] = None,
        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"""
        _payload: Dict[str, Any] = {}
        _payload["rule_id"] = rule_id
        if id is not None:
            _payload["id"] = id
        if name is not None:
            _payload["name"] = name
        if update_stats is not None:
            _payload["update_stats"] = update_stats
        return await self._call("alerts.evaluate", params=_payload, options=options, context=context)

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

        Args:
        rule_id: Rule ID"""
        _payload: Dict[str, Any] = {}
        _payload["rule_id"] = rule_id
        if id is not None:
            _payload["id"] = id
        if name is not None:
            _payload["name"] = name
        return await self._call("alerts.get", params=_payload, options=options, context=context)

    async def history(
        self,
        *,
        ack: Optional[str] = None,
        id: Optional[str] = None,
        offset: Optional[int] = None,
        rule_id: Optional[str] = None,
        limit: Optional[int] = 100,
        status: Optional[str] = None,
        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"""
        _payload: Dict[str, Any] = {}
        if ack is not None:
            _payload["ack"] = ack
        if id is not None:
            _payload["id"] = id
        if offset is not None:
            _payload["offset"] = offset
        if rule_id is not None:
            _payload["rule_id"] = rule_id
        if limit is not None:
            _payload["limit"] = limit
        if status is not None:
            _payload["status"] = status
        return await self._call("alerts.history", params=_payload, options=options, context=context, response_format=response_format)

    async def list(
        self,
        *,
        enabled: Optional[bool] = None,
        limit: Optional[int] = 100,
        offset: Optional[int] = None,
        order: Optional[str] = None,
        rule_type: Optional[str] = None,
        search: Optional[str] = None,
        sort: Optional[str] = None,
        type_: Optional[str] = None,
        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"""
        _payload: Dict[str, Any] = {}
        if enabled is not None:
            _payload["enabled"] = enabled
        if limit is not None:
            _payload["limit"] = limit
        if offset is not None:
            _payload["offset"] = offset
        if order is not None:
            _payload["order"] = order
        if rule_type is not None:
            _payload["rule_type"] = rule_type
        if search is not None:
            _payload["search"] = search
        if sort is not None:
            _payload["sort"] = sort
        if type_ is not None:
            _payload["type"] = type_
        return await self._call("alerts.list", params=_payload, options=options, context=context, response_format=response_format)

    async def run(
        self,
        *,
        dry_run: Optional[str] = None,
        force: Optional[str] = None,
        id: Optional[str] = None,
        limit: Optional[int] = None,
        name: Optional[str] = None,
        rule_id: Optional[str] = None,
        rule_type: Optional[str] = None,
        type_: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Run all alerts

        Evaluate all enabled alerts."""
        _payload: Dict[str, Any] = {}
        if dry_run is not None:
            _payload["dry_run"] = dry_run
        if force is not None:
            _payload["force"] = force
        if id is not None:
            _payload["id"] = id
        if limit is not None:
            _payload["limit"] = limit
        if name is not None:
            _payload["name"] = name
        if rule_id is not None:
            _payload["rule_id"] = rule_id
        if rule_type is not None:
            _payload["rule_type"] = rule_type
        if type_ is not None:
            _payload["type"] = type_
        return await self._call("alerts.run", params=_payload, options=options, context=context)

    async def update(
        self,
        *,
        rule_id: str,
        config: Optional[Dict[str, Any]] = None,
        cooldown_seconds: Optional[str] = None,
        delivery: Optional[str] = None,
        description: Optional[str] = None,
        id: Optional[str] = None,
        new_name: Optional[str] = None,
        name: Optional[str] = None,
        enabled: Optional[bool] = None,
        rule_type: Optional[str] = None,
        severity: Optional[str] = None,
        type_: Optional[str] = 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
        enabled: Enable/disable"""
        _payload: Dict[str, Any] = {}
        _payload["rule_id"] = rule_id
        if config is not None:
            _payload["config"] = config
        if cooldown_seconds is not None:
            _payload["cooldown_seconds"] = cooldown_seconds
        if delivery is not None:
            _payload["delivery"] = delivery
        if description is not None:
            _payload["description"] = description
        if id is not None:
            _payload["id"] = id
        if new_name is not None:
            _payload["new_name"] = new_name
        if name is not None:
            _payload["name"] = name
        if enabled is not None:
            _payload["enabled"] = enabled
        if rule_type is not None:
            _payload["rule_type"] = rule_type
        if severity is not None:
            _payload["severity"] = severity
        if type_ is not None:
            _payload["type"] = type_
        return await self._call("alerts.update", params=_payload, options=options, context=context)


