from collections.abc import Mapping
from typing import Any, TypeVar, Optional, BinaryIO, TextIO, TYPE_CHECKING, Generator

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

from ..types import UNSET, Unset

from ..types import UNSET, Unset
from dateutil.parser import isoparse
from typing import cast
from typing import cast, Union
from typing import Union
import datetime

if TYPE_CHECKING:
  from ..models.entity_tag_header_value import EntityTagHeaderValue





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



@_attrs_define
class FileResult:
    """ 
        Attributes:
            content_type (Union[None, Unset, str]):
            file_download_name (Union[None, Unset, str]):
            last_modified (Union[None, Unset, datetime.datetime]):
            entity_tag (Union['EntityTagHeaderValue', Any, Unset]):
            enable_range_processing (Union[Unset, bool]):
     """

    content_type: Union[None, Unset, str] = UNSET
    file_download_name: Union[None, Unset, str] = UNSET
    last_modified: Union[None, Unset, datetime.datetime] = UNSET
    entity_tag: Union['EntityTagHeaderValue', Any, Unset] = UNSET
    enable_range_processing: Union[Unset, bool] = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)





    def to_dict(self) -> dict[str, Any]:
        from ..models.entity_tag_header_value import EntityTagHeaderValue
        content_type: Union[None, Unset, str]
        if isinstance(self.content_type, Unset):
            content_type = UNSET
        else:
            content_type = self.content_type

        file_download_name: Union[None, Unset, str]
        if isinstance(self.file_download_name, Unset):
            file_download_name = UNSET
        else:
            file_download_name = self.file_download_name

        last_modified: Union[None, Unset, str]
        if isinstance(self.last_modified, Unset):
            last_modified = UNSET
        elif isinstance(self.last_modified, datetime.datetime):
            last_modified = self.last_modified.isoformat()
        else:
            last_modified = self.last_modified

        entity_tag: Union[Any, Unset, dict[str, Any]]
        if isinstance(self.entity_tag, Unset):
            entity_tag = UNSET
        elif isinstance(self.entity_tag, EntityTagHeaderValue):
            entity_tag = self.entity_tag.to_dict()
        else:
            entity_tag = self.entity_tag

        enable_range_processing = self.enable_range_processing


        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({
        })
        if content_type is not UNSET:
            field_dict["contentType"] = content_type
        if file_download_name is not UNSET:
            field_dict["fileDownloadName"] = file_download_name
        if last_modified is not UNSET:
            field_dict["lastModified"] = last_modified
        if entity_tag is not UNSET:
            field_dict["entityTag"] = entity_tag
        if enable_range_processing is not UNSET:
            field_dict["enableRangeProcessing"] = enable_range_processing

        return field_dict



    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.entity_tag_header_value import EntityTagHeaderValue
        d = dict(src_dict)
        def _parse_content_type(data: object) -> Union[None, Unset, str]:
            if data is None:
                return data
            if isinstance(data, Unset):
                return data
            return cast(Union[None, Unset, str], data)

        content_type = _parse_content_type(d.pop("contentType", UNSET))


        def _parse_file_download_name(data: object) -> Union[None, Unset, str]:
            if data is None:
                return data
            if isinstance(data, Unset):
                return data
            return cast(Union[None, Unset, str], data)

        file_download_name = _parse_file_download_name(d.pop("fileDownloadName", UNSET))


        def _parse_last_modified(data: object) -> Union[None, Unset, datetime.datetime]:
            if data is None:
                return data
            if isinstance(data, Unset):
                return data
            try:
                if not isinstance(data, str):
                    raise TypeError()
                last_modified_type_0 = isoparse(data)



                return last_modified_type_0
            except: # noqa: E722
                pass
            return cast(Union[None, Unset, datetime.datetime], data)

        last_modified = _parse_last_modified(d.pop("lastModified", UNSET))


        def _parse_entity_tag(data: object) -> Union['EntityTagHeaderValue', Any, Unset]:
            if isinstance(data, Unset):
                return data
            try:
                if not isinstance(data, dict):
                    raise TypeError()
                entity_tag_type_1 = EntityTagHeaderValue.from_dict(data)



                return entity_tag_type_1
            except: # noqa: E722
                pass
            return cast(Union['EntityTagHeaderValue', Any, Unset], data)

        entity_tag = _parse_entity_tag(d.pop("entityTag", UNSET))


        enable_range_processing = d.pop("enableRangeProcessing", UNSET)

        file_result = cls(
            content_type=content_type,
            file_download_name=file_download_name,
            last_modified=last_modified,
            entity_tag=entity_tag,
            enable_range_processing=enable_range_processing,
        )


        file_result.additional_properties = d
        return file_result

    @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
