from typing import Any

from csirtmu.beta.rt_queue import Queue
from csirtmu.beta_temporal.constants import WorkflowReference
from csirtmu.beta_temporal.external_services.rt.structs import TransactionTypeEnum


class QueueBuilder:
    def __init__(
        self,
        name: str,
        temporal_queue: str,
    ) -> None:
        self.queue = Queue(name, temporal_queue)

    def to_queue(self) -> Queue:
        return self.queue

    def add_rule(
        self, transaction_type: TransactionTypeEnum, workflow: WorkflowReference, params: dict[str, Any] | None = None
    ) -> "QueueBuilder":
        self.queue.add_rule(transaction_type, workflow, params)
        return self
