from __future__ import annotations

from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar

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

from ..types import UNSET, Unset

if TYPE_CHECKING:
    from ..models.legacytypes_e_fast_data import LegacytypesEFastData


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


@_attrs_define
class LegacytypesInternalTaskData:
    """
    Attributes:
        efast_data (LegacytypesEFastData | Unset):
        form_id (str | Unset):
        py (str | Unset):
        task_type (str | Unset):
        url (str | Unset):
    """

    efast_data: LegacytypesEFastData | Unset = UNSET
    form_id: str | Unset = UNSET
    py: str | Unset = UNSET
    task_type: str | Unset = UNSET
    url: str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        efast_data: dict[str, Any] | Unset = UNSET
        if not isinstance(self.efast_data, Unset):
            efast_data = self.efast_data.to_dict()

        form_id = self.form_id

        py = self.py

        task_type = self.task_type

        url = self.url

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if efast_data is not UNSET:
            field_dict["efast_data"] = efast_data
        if form_id is not UNSET:
            field_dict["form_id"] = form_id
        if py is not UNSET:
            field_dict["py"] = py
        if task_type is not UNSET:
            field_dict["task_type"] = task_type
        if url is not UNSET:
            field_dict["url"] = url

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.legacytypes_e_fast_data import LegacytypesEFastData

        d = dict(src_dict)
        _efast_data = d.pop("efast_data", UNSET)
        efast_data: LegacytypesEFastData | Unset
        if isinstance(_efast_data, Unset):
            efast_data = UNSET
        else:
            efast_data = LegacytypesEFastData.from_dict(_efast_data)

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

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

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

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

        legacytypes_internal_task_data = cls(
            efast_data=efast_data,
            form_id=form_id,
            py=py,
            task_type=task_type,
            url=url,
        )

        legacytypes_internal_task_data.additional_properties = d
        return legacytypes_internal_task_data

    @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
