from __future__ import annotations

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

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

from ..types import UNSET, Unset

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


@_attrs_define
class PkgRoutesFilesSearchRequest:
    """
    Attributes:
        extensions (list[str] | Unset):
        folders_only (bool | Unset):
        parent (str | Unset):
        q (str | Unset):
    """

    extensions: list[str] | Unset = UNSET
    folders_only: bool | Unset = UNSET
    parent: str | Unset = UNSET
    q: str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        folders_only = self.folders_only

        parent = self.parent

        q = self.q

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if extensions is not UNSET:
            field_dict["extensions"] = extensions
        if folders_only is not UNSET:
            field_dict["folders_only"] = folders_only
        if parent is not UNSET:
            field_dict["parent"] = parent
        if q is not UNSET:
            field_dict["q"] = q

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        d = dict(src_dict)
        extensions = cast(list[str], d.pop("extensions", UNSET))

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

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

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

        pkg_routes_files_search_request = cls(
            extensions=extensions,
            folders_only=folders_only,
            parent=parent,
            q=q,
        )

        pkg_routes_files_search_request.additional_properties = d
        return pkg_routes_files_search_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
