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="PkgRoutesPackagesRetirementFormatsImportProvisionsRequest")


@_attrs_define
class PkgRoutesPackagesRetirementFormatsImportProvisionsRequest:
    """
    Attributes:
        bulk (bool | Unset):
        file (list[int] | Unset):
        format_ (str | Unset):
        plan_id (str | Unset):
        row_number (int | Unset):
    """

    bulk: bool | Unset = UNSET
    file: list[int] | Unset = UNSET
    format_: str | Unset = UNSET
    plan_id: str | Unset = UNSET
    row_number: int | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

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

        format_ = self.format_

        plan_id = self.plan_id

        row_number = self.row_number

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if bulk is not UNSET:
            field_dict["bulk"] = bulk
        if file is not UNSET:
            field_dict["file"] = file
        if format_ is not UNSET:
            field_dict["format"] = format_
        if plan_id is not UNSET:
            field_dict["planId"] = plan_id
        if row_number is not UNSET:
            field_dict["row_number"] = row_number

        return field_dict

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

        file = cast(list[int], d.pop("file", UNSET))

        format_ = d.pop("format", UNSET)

        plan_id = d.pop("planId", UNSET)

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

        pkg_routes_packages_retirement_formats_import_provisions_request = cls(
            bulk=bulk,
            file=file,
            format_=format_,
            plan_id=plan_id,
            row_number=row_number,
        )

        pkg_routes_packages_retirement_formats_import_provisions_request.additional_properties = d
        return pkg_routes_packages_retirement_formats_import_provisions_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
