# coding: utf-8

"""
Hatchet API

The Hatchet API

The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
"""  # noqa: E501

from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from hatchet_sdk.clients.rest.models.v1_durable_event_log_kind import (
    V1DurableEventLogKind,
)
from hatchet_sdk.clients.rest.models.v1_durable_wait_condition_kind import (
    V1DurableWaitConditionKind,
)
from typing import Optional, Set
from typing_extensions import Self


class V1DurableEventLogEntry(BaseModel):
    """
    V1DurableEventLogEntry
    """  # noqa: E501

    node_id: StrictInt = Field(
        description="The monotonically increasing node id in the event log.",
        alias="nodeId",
    )
    branch_id: StrictInt = Field(
        description="The branch id when this entry was first seen.", alias="branchId"
    )
    kind: V1DurableEventLogKind
    wait_condition_kind: Optional[V1DurableWaitConditionKind] = Field(
        default=None, alias="waitConditionKind"
    )
    is_satisfied: StrictBool = Field(
        description="Whether this entry has been satisfied.", alias="isSatisfied"
    )
    satisfied_at: Optional[datetime] = Field(
        default=None,
        description="When this entry was satisfied, if it has been satisfied.",
        alias="satisfiedAt",
    )
    inserted_at: datetime = Field(
        description="When this entry was inserted.", alias="insertedAt"
    )
    user_message: Optional[StrictStr] = Field(
        default=None,
        description="A user-provided message or label, send when establishing a durable wait",
        alias="userMessage",
    )
    human_readable_message: Optional[StrictStr] = Field(
        default=None,
        description="A human-readable message, generated by the engine, describing the current status of a durable task",
        alias="humanReadableMessage",
    )
    __properties: ClassVar[List[str]] = [
        "nodeId",
        "branchId",
        "kind",
        "waitConditionKind",
        "isSatisfied",
        "satisfiedAt",
        "insertedAt",
        "userMessage",
        "humanReadableMessage",
    ]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of V1DurableEventLogEntry from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of V1DurableEventLogEntry from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate(
            {
                "nodeId": obj.get("nodeId"),
                "branchId": obj.get("branchId"),
                "kind": obj.get("kind"),
                "waitConditionKind": obj.get("waitConditionKind"),
                "isSatisfied": obj.get("isSatisfied"),
                "satisfiedAt": obj.get("satisfiedAt"),
                "insertedAt": obj.get("insertedAt"),
                "userMessage": obj.get("userMessage"),
                "humanReadableMessage": obj.get("humanReadableMessage"),
            }
        )
        return _obj
