from __future__ import annotations

from collections.abc import Mapping
from typing import Any, Literal, TypeVar, cast

from attrs import define as _attrs_define
from attrs import field as _attrs_field

from ..types import UNSET, Unset

T = TypeVar("T", bound="IntervalTriggerModel")


@_attrs_define
class IntervalTriggerModel:
    """
    Attributes:
        trigger (Literal['interval'] | Unset):  Default: 'interval'.
        seconds (int | Unset):  Default: 86400.
    """

    trigger: Literal["interval"] | Unset = "interval"
    seconds: int | Unset = 86400
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        trigger = self.trigger

        seconds = self.seconds

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if trigger is not UNSET:
            field_dict["trigger"] = trigger
        if seconds is not UNSET:
            field_dict["seconds"] = seconds

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        d = dict(src_dict)
        trigger = cast(Literal["interval"] | Unset, d.pop("trigger", UNSET))
        if trigger != "interval" and not isinstance(trigger, Unset):
            raise ValueError(f"trigger must match const 'interval', got '{trigger}'")

        seconds = d.pop("seconds", UNSET)

        interval_trigger_model = cls(
            trigger=trigger,
            seconds=seconds,
        )

        interval_trigger_model.additional_properties = d
        return interval_trigger_model

    @property
    def additional_keys(self) -> list[str]:
        return list(self.additional_properties.keys())

    def __getitem__(self, key: str) -> Any:
        return self.additional_properties[key]

    def __setitem__(self, key: str, value: Any) -> None:
        self.additional_properties[key] = value

    def __delitem__(self, key: str) -> None:
        del self.additional_properties[key]

    def __contains__(self, key: str) -> bool:
        return key in self.additional_properties
