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.types_saved_filter_filter import TypesSavedFilterFilter


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


@_attrs_define
class TypesSavedFilter:
    """
    Attributes:
        field_id (str | Unset):
        deleted_at (str | Unset):
        filter_ (TypesSavedFilterFilter | Unset):
        name (str | Unset):
        on_type (str | Unset):
        team (str | Unset):
        user (str | Unset):
    """

    field_id: str | Unset = UNSET
    deleted_at: str | Unset = UNSET
    filter_: TypesSavedFilterFilter | Unset = UNSET
    name: str | Unset = UNSET
    on_type: str | Unset = UNSET
    team: str | Unset = UNSET
    user: str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        field_id = self.field_id

        deleted_at = self.deleted_at

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

        name = self.name

        on_type = self.on_type

        team = self.team

        user = self.user

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if field_id is not UNSET:
            field_dict["_id"] = field_id
        if deleted_at is not UNSET:
            field_dict["deleted_at"] = deleted_at
        if filter_ is not UNSET:
            field_dict["filter"] = filter_
        if name is not UNSET:
            field_dict["name"] = name
        if on_type is not UNSET:
            field_dict["on_type"] = on_type
        if team is not UNSET:
            field_dict["team"] = team
        if user is not UNSET:
            field_dict["user"] = user

        return field_dict

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

        d = dict(src_dict)
        field_id = d.pop("_id", UNSET)

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

        _filter_ = d.pop("filter", UNSET)
        filter_: TypesSavedFilterFilter | Unset
        if isinstance(_filter_, Unset):
            filter_ = UNSET
        else:
            filter_ = TypesSavedFilterFilter.from_dict(_filter_)

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

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

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

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

        types_saved_filter = cls(
            field_id=field_id,
            deleted_at=deleted_at,
            filter_=filter_,
            name=name,
            on_type=on_type,
            team=team,
            user=user,
        )

        types_saved_filter.additional_properties = d
        return types_saved_filter

    @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
