"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from enum import Enum
from novu_py.types import BaseModel
import pydantic
from typing import Any, Dict, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class ThrottleControlDtoType(str, Enum):
    r"""The type of throttle window."""

    FIXED = "fixed"
    DYNAMIC = "dynamic"


class ThrottleControlDtoUnit(str, Enum):
    r"""The unit of time for the throttle window (required for fixed type)."""

    MINUTES = "minutes"
    HOURS = "hours"
    DAYS = "days"


class ThrottleControlDtoTypedDict(TypedDict):
    skip: NotRequired[Dict[str, Any]]
    r"""JSONLogic filter conditions for conditionally skipping the step execution. Supports complex logical operations with AND, OR, and comparison operators. See https://jsonlogic.com/ for full typing reference."""
    type: NotRequired[ThrottleControlDtoType]
    r"""The type of throttle window."""
    amount: NotRequired[float]
    r"""The amount of time for the throttle window (required for fixed type)."""
    unit: NotRequired[ThrottleControlDtoUnit]
    r"""The unit of time for the throttle window (required for fixed type)."""
    dynamic_key: NotRequired[str]
    r"""Key path to retrieve dynamic window value (required for dynamic type)."""
    threshold: NotRequired[float]
    r"""The maximum number of executions allowed within the window. Defaults to 1."""
    throttle_key: NotRequired[str]
    r"""Optional key for grouping throttle rules. If not provided, defaults to workflow and subscriber combination."""


class ThrottleControlDto(BaseModel):
    skip: Optional[Dict[str, Any]] = None
    r"""JSONLogic filter conditions for conditionally skipping the step execution. Supports complex logical operations with AND, OR, and comparison operators. See https://jsonlogic.com/ for full typing reference."""

    type: Optional[ThrottleControlDtoType] = ThrottleControlDtoType.FIXED
    r"""The type of throttle window."""

    amount: Optional[float] = None
    r"""The amount of time for the throttle window (required for fixed type)."""

    unit: Optional[ThrottleControlDtoUnit] = None
    r"""The unit of time for the throttle window (required for fixed type)."""

    dynamic_key: Annotated[Optional[str], pydantic.Field(alias="dynamicKey")] = None
    r"""Key path to retrieve dynamic window value (required for dynamic type)."""

    threshold: Optional[float] = 1
    r"""The maximum number of executions allowed within the window. Defaults to 1."""

    throttle_key: Annotated[Optional[str], pydantic.Field(alias="throttleKey")] = None
    r"""Optional key for grouping throttle rules. If not provided, defaults to workflow and subscriber combination."""
