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_misc_create_initial_context_request_custom import (
        PkgRoutesMiscCreateInitialContextRequestCustom,
    )


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


@_attrs_define
class PkgRoutesMiscCreateInitialContextRequest:
    """
    Attributes:
        client (str | Unset):
        custom (PkgRoutesMiscCreateInitialContextRequestCustom | Unset):
        deal (str | Unset):
        plan (str | Unset):
        project (str | Unset):
        strict (bool | Unset):
        task (str | Unset):
    """

    client: str | Unset = UNSET
    custom: PkgRoutesMiscCreateInitialContextRequestCustom | Unset = UNSET
    deal: str | Unset = UNSET
    plan: str | Unset = UNSET
    project: str | Unset = UNSET
    strict: bool | Unset = UNSET
    task: str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

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

        deal = self.deal

        plan = self.plan

        project = self.project

        strict = self.strict

        task = self.task

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if client is not UNSET:
            field_dict["client"] = client
        if custom is not UNSET:
            field_dict["custom"] = custom
        if deal is not UNSET:
            field_dict["deal"] = deal
        if plan is not UNSET:
            field_dict["plan"] = plan
        if project is not UNSET:
            field_dict["project"] = project
        if strict is not UNSET:
            field_dict["strict"] = strict
        if task is not UNSET:
            field_dict["task"] = task

        return field_dict

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

        d = dict(src_dict)
        client = d.pop("client", UNSET)

        _custom = d.pop("custom", UNSET)
        custom: PkgRoutesMiscCreateInitialContextRequestCustom | Unset
        if isinstance(_custom, Unset):
            custom = UNSET
        else:
            custom = PkgRoutesMiscCreateInitialContextRequestCustom.from_dict(_custom)

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

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

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

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

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

        pkg_routes_misc_create_initial_context_request = cls(
            client=client,
            custom=custom,
            deal=deal,
            plan=plan,
            project=project,
            strict=strict,
            task=task,
        )

        pkg_routes_misc_create_initial_context_request.additional_properties = d
        return pkg_routes_misc_create_initial_context_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
