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.pkg_routes_library_forms_list_response_filters import PkgRoutesLibraryFormsListResponseFilters
    from ..models.types_list_pagination import TypesListPagination
    from ..models.types_list_sort import TypesListSort


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


@_attrs_define
class PkgRoutesLibraryFormsListResponseRequest:
    """
    Attributes:
        filters (PkgRoutesLibraryFormsListResponseFilters | Unset):
        page (TypesListPagination | Unset):
        sort (TypesListSort | Unset):
    """

    filters: PkgRoutesLibraryFormsListResponseFilters | Unset = UNSET
    page: TypesListPagination | Unset = UNSET
    sort: TypesListSort | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

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

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

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if filters is not UNSET:
            field_dict["filters"] = filters
        if page is not UNSET:
            field_dict["page"] = page
        if sort is not UNSET:
            field_dict["sort"] = sort

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.pkg_routes_library_forms_list_response_filters import PkgRoutesLibraryFormsListResponseFilters
        from ..models.types_list_pagination import TypesListPagination
        from ..models.types_list_sort import TypesListSort

        d = dict(src_dict)
        _filters = d.pop("filters", UNSET)
        filters: PkgRoutesLibraryFormsListResponseFilters | Unset
        if isinstance(_filters, Unset):
            filters = UNSET
        else:
            filters = PkgRoutesLibraryFormsListResponseFilters.from_dict(_filters)

        _page = d.pop("page", UNSET)
        page: TypesListPagination | Unset
        if isinstance(_page, Unset):
            page = UNSET
        else:
            page = TypesListPagination.from_dict(_page)

        _sort = d.pop("sort", UNSET)
        sort: TypesListSort | Unset
        if isinstance(_sort, Unset):
            sort = UNSET
        else:
            sort = TypesListSort.from_dict(_sort)

        pkg_routes_library_forms_list_response_request = cls(
            filters=filters,
            page=page,
            sort=sort,
        )

        pkg_routes_library_forms_list_response_request.additional_properties = d
        return pkg_routes_library_forms_list_response_request

    @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
