from typing import Any
from typing import Dict
from typing import List
from typing import Type
from typing import TypeVar

from attrs import define as _attrs_define

from ..models.task_queue_entry import TaskQueueEntry


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


@_attrs_define
class TasksQueued:
    """TasksQueued model

    Attributes:
        queue (List['TaskQueueEntry']):
    """

    queue: List["TaskQueueEntry"]

    def to_dict(self) -> Dict[str, Any]:
        """Convert to a dict"""
        queue = []
        for queue_item_data in self.queue:
            queue_item = queue_item_data.to_dict()
            queue.append(queue_item)

        field_dict: Dict[str, Any] = {}
        field_dict.update(
            {
                "queue": queue,
            }
        )

        return field_dict

    @classmethod
    def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
        """Create an instance of :py:class:`TasksQueued` from a dict"""
        d = src_dict.copy()
        queue = []
        _queue = d.pop("queue")
        for queue_item_data in _queue:
            queue_item = TaskQueueEntry.from_dict(queue_item_data)

            queue.append(queue_item)

        tasks_queued = cls(
            queue=queue,
        )

        return tasks_queued
