# coding: utf-8

"""
    FlowHunt

    FlowHunt API

    The version of the OpenAPI document: 2.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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from flowhunt.models.flow_cron_status import FlowCronStatus
from typing import Optional, Set
from typing_extensions import Self

class FlowCronResponse(BaseModel):
    """
    Flow cron response.
    """ # noqa: E501
    flow_id: StrictStr
    cron_id: StrictStr
    last_run: Optional[datetime] = None
    next_run: Optional[datetime] = None
    status: FlowCronStatus
    input_text: Optional[StrictStr] = None
    interval_settings: StrictStr
    variables: Optional[Dict[str, Any]] = None
    cron_name: StrictStr
    __properties: ClassVar[List[str]] = ["flow_id", "cron_id", "last_run", "next_run", "status", "input_text", "interval_settings", "variables", "cron_name"]

    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 FlowCronResponse 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,
        )
        # set to None if last_run (nullable) is None
        # and model_fields_set contains the field
        if self.last_run is None and "last_run" in self.model_fields_set:
            _dict['last_run'] = None

        # set to None if next_run (nullable) is None
        # and model_fields_set contains the field
        if self.next_run is None and "next_run" in self.model_fields_set:
            _dict['next_run'] = None

        # set to None if input_text (nullable) is None
        # and model_fields_set contains the field
        if self.input_text is None and "input_text" in self.model_fields_set:
            _dict['input_text'] = None

        # set to None if variables (nullable) is None
        # and model_fields_set contains the field
        if self.variables is None and "variables" in self.model_fields_set:
            _dict['variables'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "flow_id": obj.get("flow_id"),
            "cron_id": obj.get("cron_id"),
            "last_run": obj.get("last_run"),
            "next_run": obj.get("next_run"),
            "status": obj.get("status"),
            "input_text": obj.get("input_text"),
            "interval_settings": obj.get("interval_settings"),
            "variables": obj.get("variables"),
            "cron_name": obj.get("cron_name")
        })
        return _obj


