# coding: utf-8

"""
    Agent Management API

    API for managing agents, their templates, and call logs

    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 pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from smallestai.atoms.models.agent_id_workflow_get200_response_data_edges_inner_data import AgentIdWorkflowGet200ResponseDataEdgesInnerData
from smallestai.atoms.models.agent_id_workflow_get200_response_data_edges_inner_marker_end import AgentIdWorkflowGet200ResponseDataEdgesInnerMarkerEnd
from typing import Optional, Set
from typing_extensions import Self

class AgentIdWorkflowGet200ResponseDataEdgesInner(BaseModel):
    """
    AgentIdWorkflowGet200ResponseDataEdgesInner
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="Unique identifier for the edge")
    source: Optional[StrictStr] = Field(default=None, description="ID of the source node")
    source_handle: Optional[StrictStr] = Field(default=None, description="Source handle ID", alias="sourceHandle")
    target: Optional[StrictStr] = Field(default=None, description="ID of the target node")
    target_handle: Optional[StrictStr] = Field(default=None, description="Target handle ID", alias="targetHandle")
    type: Optional[StrictStr] = Field(default=None, description="Type of the edge (e.g., smoothstep, direct)")
    label: Optional[StrictStr] = Field(default=None, description="Label for the edge")
    description: Optional[StrictStr] = Field(default=None, description="Description of the edge")
    selected: Optional[StrictBool] = None
    animated: Optional[StrictBool] = None
    marker_end: Optional[AgentIdWorkflowGet200ResponseDataEdgesInnerMarkerEnd] = Field(default=None, alias="markerEnd")
    data: Optional[AgentIdWorkflowGet200ResponseDataEdgesInnerData] = None
    __properties: ClassVar[List[str]] = ["id", "source", "sourceHandle", "target", "targetHandle", "type", "label", "description", "selected", "animated", "markerEnd", "data"]

    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 AgentIdWorkflowGet200ResponseDataEdgesInner 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,
        )
        # override the default output from pydantic by calling `to_dict()` of marker_end
        if self.marker_end:
            _dict['markerEnd'] = self.marker_end.to_dict()
        # override the default output from pydantic by calling `to_dict()` of data
        if self.data:
            _dict['data'] = self.data.to_dict()
        # set to None if source_handle (nullable) is None
        # and model_fields_set contains the field
        if self.source_handle is None and "source_handle" in self.model_fields_set:
            _dict['sourceHandle'] = None

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

        return _dict

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

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

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "source": obj.get("source"),
            "sourceHandle": obj.get("sourceHandle"),
            "target": obj.get("target"),
            "targetHandle": obj.get("targetHandle"),
            "type": obj.get("type"),
            "label": obj.get("label"),
            "description": obj.get("description"),
            "selected": obj.get("selected"),
            "animated": obj.get("animated"),
            "markerEnd": AgentIdWorkflowGet200ResponseDataEdgesInnerMarkerEnd.from_dict(obj["markerEnd"]) if obj.get("markerEnd") is not None else None,
            "data": AgentIdWorkflowGet200ResponseDataEdgesInnerData.from_dict(obj["data"]) if obj.get("data") is not None else None
        })
        return _obj


