from __future__ import annotations

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

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_list_filter_data import TypesListFilterData
    from ..models.types_plans_filter_provisions import TypesPlansFilterProvisions


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


@_attrs_define
class TypesPlansFilter:
    """
    Attributes:
        client (list[str] | Unset):
        data (list[TypesListFilterData] | Unset):
        provisions (TypesPlansFilterProvisions | Unset):
        pye (Any | Unset):
        status (list[str] | Unset):
        tags (list[str] | Unset):
        type_ (list[str] | Unset):
    """

    client: list[str] | Unset = UNSET
    data: list[TypesListFilterData] | Unset = UNSET
    provisions: TypesPlansFilterProvisions | Unset = UNSET
    pye: Any | Unset = UNSET
    status: list[str] | Unset = UNSET
    tags: list[str] | Unset = UNSET
    type_: list[str] | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        data: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.data, Unset):
            data = []
            for data_item_data in self.data:
                data_item = data_item_data.to_dict()
                data.append(data_item)

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

        pye = self.pye

        status: list[str] | Unset = UNSET
        if not isinstance(self.status, Unset):
            status = self.status

        tags: list[str] | Unset = UNSET
        if not isinstance(self.tags, Unset):
            tags = self.tags

        type_: list[str] | Unset = UNSET
        if not isinstance(self.type_, Unset):
            type_ = self.type_

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if client is not UNSET:
            field_dict["client"] = client
        if data is not UNSET:
            field_dict["data"] = data
        if provisions is not UNSET:
            field_dict["provisions"] = provisions
        if pye is not UNSET:
            field_dict["pye"] = pye
        if status is not UNSET:
            field_dict["status"] = status
        if tags is not UNSET:
            field_dict["tags"] = tags
        if type_ is not UNSET:
            field_dict["type"] = type_

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.types_list_filter_data import TypesListFilterData
        from ..models.types_plans_filter_provisions import TypesPlansFilterProvisions

        d = dict(src_dict)
        client = cast(list[str], d.pop("client", UNSET))

        _data = d.pop("data", UNSET)
        data: list[TypesListFilterData] | Unset = UNSET
        if _data is not UNSET:
            data = []
            for data_item_data in _data:
                data_item = TypesListFilterData.from_dict(data_item_data)

                data.append(data_item)

        _provisions = d.pop("provisions", UNSET)
        provisions: TypesPlansFilterProvisions | Unset
        if isinstance(_provisions, Unset):
            provisions = UNSET
        else:
            provisions = TypesPlansFilterProvisions.from_dict(_provisions)

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

        status = cast(list[str], d.pop("status", UNSET))

        tags = cast(list[str], d.pop("tags", UNSET))

        type_ = cast(list[str], d.pop("type", UNSET))

        types_plans_filter = cls(
            client=client,
            data=data,
            provisions=provisions,
            pye=pye,
            status=status,
            tags=tags,
            type_=type_,
        )

        types_plans_filter.additional_properties = d
        return types_plans_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
