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_filters_client import LegacytypesFiltersClient
    from ..models.legacytypes_filters_message import LegacytypesFiltersMessage
    from ..models.legacytypes_filters_plan import LegacytypesFiltersPlan
    from ..models.legacytypes_filters_project import LegacytypesFiltersProject
    from ..models.legacytypes_filters_task import LegacytypesFiltersTask


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


@_attrs_define
class LegacytypesFilters:
    """
    Attributes:
        client (LegacytypesFiltersClient | Unset):
        message (LegacytypesFiltersMessage | Unset):
        plan (LegacytypesFiltersPlan | Unset):
        project (LegacytypesFiltersProject | Unset):
        task (LegacytypesFiltersTask | Unset):
    """

    client: LegacytypesFiltersClient | Unset = UNSET
    message: LegacytypesFiltersMessage | Unset = UNSET
    plan: LegacytypesFiltersPlan | Unset = UNSET
    project: LegacytypesFiltersProject | Unset = UNSET
    task: LegacytypesFiltersTask | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        message: dict[str, Any] | Unset = UNSET
        if not isinstance(self.message, Unset):
            message = self.message.to_dict()

        plan: dict[str, Any] | Unset = UNSET
        if not isinstance(self.plan, Unset):
            plan = self.plan.to_dict()

        project: dict[str, Any] | Unset = UNSET
        if not isinstance(self.project, Unset):
            project = self.project.to_dict()

        task: dict[str, Any] | Unset = UNSET
        if not isinstance(self.task, Unset):
            task = self.task.to_dict()

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if client is not UNSET:
            field_dict["client"] = client
        if message is not UNSET:
            field_dict["message"] = message
        if plan is not UNSET:
            field_dict["plan"] = plan
        if project is not UNSET:
            field_dict["project"] = project
        if task is not UNSET:
            field_dict["task"] = task

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.legacytypes_filters_client import LegacytypesFiltersClient
        from ..models.legacytypes_filters_message import LegacytypesFiltersMessage
        from ..models.legacytypes_filters_plan import LegacytypesFiltersPlan
        from ..models.legacytypes_filters_project import LegacytypesFiltersProject
        from ..models.legacytypes_filters_task import LegacytypesFiltersTask

        d = dict(src_dict)
        _client = d.pop("client", UNSET)
        client: LegacytypesFiltersClient | Unset
        if isinstance(_client, Unset):
            client = UNSET
        else:
            client = LegacytypesFiltersClient.from_dict(_client)

        _message = d.pop("message", UNSET)
        message: LegacytypesFiltersMessage | Unset
        if isinstance(_message, Unset):
            message = UNSET
        else:
            message = LegacytypesFiltersMessage.from_dict(_message)

        _plan = d.pop("plan", UNSET)
        plan: LegacytypesFiltersPlan | Unset
        if isinstance(_plan, Unset):
            plan = UNSET
        else:
            plan = LegacytypesFiltersPlan.from_dict(_plan)

        _project = d.pop("project", UNSET)
        project: LegacytypesFiltersProject | Unset
        if isinstance(_project, Unset):
            project = UNSET
        else:
            project = LegacytypesFiltersProject.from_dict(_project)

        _task = d.pop("task", UNSET)
        task: LegacytypesFiltersTask | Unset
        if isinstance(_task, Unset):
            task = UNSET
        else:
            task = LegacytypesFiltersTask.from_dict(_task)

        legacytypes_filters = cls(
            client=client,
            message=message,
            plan=plan,
            project=project,
            task=task,
        )

        legacytypes_filters.additional_properties = d
        return legacytypes_filters

    @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
