from __future__ import annotations

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

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

from ..types import UNSET, Unset

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


@_attrs_define
class TypesInternalTaskDataTemplate:
    """
    Attributes:
        form_id (str | Unset):
        py (str | Unset):
        task_type (str | Unset):
        url (str | 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]:
        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 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:
        d = dict(src_dict)
        form_id = d.pop("form_id", UNSET)

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

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

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

        types_internal_task_data_template = cls(
            form_id=form_id,
            py=py,
            task_type=task_type,
            url=url,
        )

        types_internal_task_data_template.additional_properties = d
        return types_internal_task_data_template

    @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
