from __future__ import annotations

import datetime
from collections.abc import Mapping
from typing import Any, TypeVar

from attrs import define as _attrs_define
from attrs import field as _attrs_field
from dateutil.parser import isoparse

from ..types import UNSET, Unset

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


@_attrs_define
class SyncInfo:
    """
    Attributes:
        user (str | Unset): MongoDB ObjectId
        key (str | Unset):
        path (str | Unset):
        override (bool | Unset):
        error (str | Unset):
        step (str | Unset):
        job (str | Unset):
        is_synced (bool | Unset):
        queued_on (datetime.datetime | Unset):
        synced_on (datetime.datetime | Unset):
    """

    user: str | Unset = UNSET
    key: str | Unset = UNSET
    path: str | Unset = UNSET
    override: bool | Unset = UNSET
    error: str | Unset = UNSET
    step: str | Unset = UNSET
    job: str | Unset = UNSET
    is_synced: bool | Unset = UNSET
    queued_on: datetime.datetime | Unset = UNSET
    synced_on: datetime.datetime | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        key = self.key

        path = self.path

        override = self.override

        error = self.error

        step = self.step

        job = self.job

        is_synced = self.is_synced

        queued_on: str | Unset = UNSET
        if not isinstance(self.queued_on, Unset):
            queued_on = self.queued_on.isoformat()

        synced_on: str | Unset = UNSET
        if not isinstance(self.synced_on, Unset):
            synced_on = self.synced_on.isoformat()

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if user is not UNSET:
            field_dict["user"] = user
        if key is not UNSET:
            field_dict["key"] = key
        if path is not UNSET:
            field_dict["path"] = path
        if override is not UNSET:
            field_dict["override"] = override
        if error is not UNSET:
            field_dict["error"] = error
        if step is not UNSET:
            field_dict["step"] = step
        if job is not UNSET:
            field_dict["job"] = job
        if is_synced is not UNSET:
            field_dict["isSynced"] = is_synced
        if queued_on is not UNSET:
            field_dict["queuedOn"] = queued_on
        if synced_on is not UNSET:
            field_dict["syncedOn"] = synced_on

        return field_dict

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

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

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

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

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

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

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

        is_synced = d.pop("isSynced", UNSET)

        _queued_on = d.pop("queuedOn", UNSET)
        queued_on: datetime.datetime | Unset
        if isinstance(_queued_on, Unset):
            queued_on = UNSET
        else:
            queued_on = isoparse(_queued_on)

        _synced_on = d.pop("syncedOn", UNSET)
        synced_on: datetime.datetime | Unset
        if isinstance(_synced_on, Unset):
            synced_on = UNSET
        else:
            synced_on = isoparse(_synced_on)

        sync_info = cls(
            user=user,
            key=key,
            path=path,
            override=override,
            error=error,
            step=step,
            job=job,
            is_synced=is_synced,
            queued_on=queued_on,
            synced_on=synced_on,
        )

        sync_info.additional_properties = d
        return sync_info

    @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
