# This file is generated. Do not modify by hand.
# pylint: disable=line-too-long, unused-argument, unused-import
from dataclasses import dataclass, field
from typing import List, Optional, Dict, Any, TYPE_CHECKING
import bson


@dataclass
class TriggerState:
    """
    The complete state of a trigger.
    """

    condition: str
    """
    The firing condition for a trigger.
    """

    actions: List[str]
    """
    The actions for a trigger.
    """

    enabled: bool
    """
    The enabled state for a trigger.
    """

    fires_total: int
    """
    The number of total fires for this trigger.
    A value of -1 indicates unlimited fires.
    """

    fires_remaining: int
    """
    The number of remaining fires for this trigger.
    A value of -1 indicates unlimited fires remaining.
    """

    @staticmethod
    def zero_values() -> 'TriggerState':
        return TriggerState(
            condition="",
            actions=[],
            enabled=False,
            fires_total=0,
            fires_remaining=0,
        )

    @staticmethod
    def from_binary(data_bytes: bytes) -> 'TriggerState':
        """" Deserialize a binary representation of this class. """
        data = bson.loads(data_bytes)  # type: Dict[str, Any]
        return TriggerState.from_dict(data)

    def to_binary(self) -> bytes:
        """" Serialize this class to a binary representation. """
        return bson.dumps(self.to_dict())  # type: ignore

    def to_dict(self) -> Dict[str, Any]:
        return {
            'condition': self.condition,
            'actions': self.actions,
            'enabled': self.enabled,
            'firesTotal': self.fires_total,
            'firesRemaining': self.fires_remaining,
        }

    @staticmethod
    def from_dict(data: Dict[str, Any]) -> 'TriggerState':
        return TriggerState(
            condition=data.get('condition'),  # type: ignore
            actions=data.get('actions'),  # type: ignore
            enabled=data.get('enabled'),  # type: ignore
            fires_total=data.get('firesTotal'),  # type: ignore
            fires_remaining=data.get('firesRemaining'),  # type: ignore
        )
