from __future__ import annotations

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

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

from ..models.vector_store_file_batch_status import VectorStoreFileBatchStatus

if TYPE_CHECKING:
    from ..models.file_counts import FileCounts


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


@_attrs_define
class VectorStoreFileBatch:
    """A batch of files attached to a vector store.

    Attributes:
        id (str):
        created_at (int):
        file_counts (FileCounts):
        object_ (Literal['vector_store.files_batch']):
        status (VectorStoreFileBatchStatus):
        vector_store_id (str):
    """

    id: str
    created_at: int
    file_counts: FileCounts
    object_: Literal["vector_store.files_batch"]
    status: VectorStoreFileBatchStatus
    vector_store_id: str
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        created_at = self.created_at

        file_counts = self.file_counts.to_dict()

        object_ = self.object_

        status = self.status.value

        vector_store_id = self.vector_store_id

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update(
            {
                "id": id,
                "created_at": created_at,
                "file_counts": file_counts,
                "object": object_,
                "status": status,
                "vector_store_id": vector_store_id,
            }
        )

        return field_dict

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

        d = dict(src_dict)
        id = d.pop("id")

        created_at = d.pop("created_at")

        file_counts = FileCounts.from_dict(d.pop("file_counts"))

        object_ = cast(Literal["vector_store.files_batch"], d.pop("object"))
        if object_ != "vector_store.files_batch":
            raise ValueError(f"object must match const 'vector_store.files_batch', got '{object_}'")

        status = VectorStoreFileBatchStatus(d.pop("status"))

        vector_store_id = d.pop("vector_store_id")

        vector_store_file_batch = cls(
            id=id,
            created_at=created_at,
            file_counts=file_counts,
            object_=object_,
            status=status,
            vector_store_id=vector_store_id,
        )

        vector_store_file_batch.additional_properties = d
        return vector_store_file_batch

    @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
