from typing import Any

from csirtmu.beta_temporal.constants import WorkflowReference
from csirtmu.beta_temporal.external_services.rt.structs import TransactionTypeEnum


class Queue:
    name: str
    workflows: dict[TransactionTypeEnum, list[WorkflowReference]]

    def __init__(
        self,
        name: str,
        temporal_queue: str,
    ) -> None:
        self.name = name
        self.temporal_queue = temporal_queue
        self.transaction_rules: dict[TransactionTypeEnum, list[tuple[WorkflowReference, dict[str, Any] | None]]] = {}

    def add_rule(
        self, transaction_type: TransactionTypeEnum, workflow: WorkflowReference, params: dict[str, Any] | None = None
    ) -> None:
        if self.transaction_rules.get(transaction_type):
            return self.transaction_rules[transaction_type].append((workflow, params))
        self.transaction_rules[transaction_type] = [(workflow, params)]
        return None
