# coding: utf-8

"""
    Cyberwave API

    Cyberwave platform REST API. Use 'Bearer YOUR_TOKEN' for authentication.

    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, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class MissionExecutionSchema(BaseModel):
    """
    Schema for Mission execution response.
    """ # noqa: E501
    uuid: StrictStr
    mission_uuid: StrictStr
    twin_uuid: StrictStr
    task_sequence_snapshot: List[Optional[Dict[str, Any]]]
    parameters: Dict[str, Any]
    priority: Optional[StrictInt] = None
    start_at: Optional[datetime] = None
    dry_run: StrictBool
    idempotency_key: StrictStr
    current_step: StrictInt
    status: StrictStr
    needs_cancelled: StrictBool
    created_at: datetime
    started_at: Optional[datetime] = None
    completed_at: Optional[datetime] = None
    timeout: Optional[StrictInt] = None
    result: Dict[str, Any]
    __properties: ClassVar[List[str]] = ["uuid", "mission_uuid", "twin_uuid", "task_sequence_snapshot", "parameters", "priority", "start_at", "dry_run", "idempotency_key", "current_step", "status", "needs_cancelled", "created_at", "started_at", "completed_at", "timeout", "result"]

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "uuid": obj.get("uuid"),
            "mission_uuid": obj.get("mission_uuid"),
            "twin_uuid": obj.get("twin_uuid"),
            "task_sequence_snapshot": obj.get("task_sequence_snapshot"),
            "parameters": obj.get("parameters"),
            "priority": obj.get("priority"),
            "start_at": obj.get("start_at"),
            "dry_run": obj.get("dry_run"),
            "idempotency_key": obj.get("idempotency_key"),
            "current_step": obj.get("current_step"),
            "status": obj.get("status"),
            "needs_cancelled": obj.get("needs_cancelled"),
            "created_at": obj.get("created_at"),
            "started_at": obj.get("started_at"),
            "completed_at": obj.get("completed_at"),
            "timeout": obj.get("timeout"),
            "result": obj.get("result")
        })
        return _obj


