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.pkg_routes_todo_project_bulk_action import PkgRoutesTodoProjectBulkAction


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


@_attrs_define
class PkgRoutesTodoProjectBulkRequest:
    """
    Attributes:
        actions (list[PkgRoutesTodoProjectBulkAction] | Unset):
        ids (list[str] | Unset):
        type_ (str | Unset):
    """

    actions: list[PkgRoutesTodoProjectBulkAction] | Unset = UNSET
    ids: list[str] | Unset = UNSET
    type_: str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        actions: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.actions, Unset):
            actions = []
            for actions_item_data in self.actions:
                actions_item = actions_item_data.to_dict()
                actions.append(actions_item)

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

        type_ = self.type_

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if actions is not UNSET:
            field_dict["actions"] = actions
        if ids is not UNSET:
            field_dict["ids"] = ids
        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.pkg_routes_todo_project_bulk_action import PkgRoutesTodoProjectBulkAction

        d = dict(src_dict)
        _actions = d.pop("actions", UNSET)
        actions: list[PkgRoutesTodoProjectBulkAction] | Unset = UNSET
        if _actions is not UNSET:
            actions = []
            for actions_item_data in _actions:
                actions_item = PkgRoutesTodoProjectBulkAction.from_dict(actions_item_data)

                actions.append(actions_item)

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

        type_ = d.pop("type", UNSET)

        pkg_routes_todo_project_bulk_request = cls(
            actions=actions,
            ids=ids,
            type_=type_,
        )

        pkg_routes_todo_project_bulk_request.additional_properties = d
        return pkg_routes_todo_project_bulk_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
