# 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_nodes_inner_data_variables import AgentIdWorkflowGet200ResponseDataNodesInnerDataVariables
from typing import Optional, Set
from typing_extensions import Self

class AgentIdWorkflowGet200ResponseDataNodesInnerData(BaseModel):
    """
    Node-specific data and configuration
    """ # noqa: E501
    label: Optional[StrictStr] = Field(default=None, description="Display label for the node")
    action: Optional[StrictStr] = Field(default=None, description="The action/prompt text for the node")
    is_start_node: Optional[StrictBool] = Field(default=None, description="Whether this is the starting node", alias="isStartNode")
    static_text: Optional[StrictBool] = Field(default=None, description="Whether the text is static", alias="staticText")
    knowledge_base: Optional[StrictStr] = Field(default=None, description="Knowledge base ID for the node", alias="knowledgeBase")
    use_global_knowledge_base: Optional[StrictBool] = Field(default=None, description="Whether to use global knowledge base", alias="useGlobalKnowledgeBase")
    is_disconnected: Optional[StrictBool] = Field(default=None, description="Whether the node is disconnected", alias="isDisconnected")
    type: Optional[StrictStr] = Field(default=None, description="Node type")
    variables: Optional[AgentIdWorkflowGet200ResponseDataNodesInnerDataVariables] = None
    has_error: Optional[StrictBool] = Field(default=None, alias="hasError")
    validation_errors: Optional[List[StrictStr]] = Field(default=None, alias="validationErrors")
    http_request: Optional[Dict[str, Any]] = Field(default=None, description="HTTP request configuration (for pre_call_api nodes)", alias="httpRequest")
    response_data: Optional[Dict[str, Any]] = Field(default=None, description="Response data configuration (for pre_call_api nodes)", alias="responseData")
    __properties: ClassVar[List[str]] = ["label", "action", "isStartNode", "staticText", "knowledgeBase", "useGlobalKnowledgeBase", "isDisconnected", "type", "variables", "hasError", "validationErrors", "httpRequest", "responseData"]

    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 AgentIdWorkflowGet200ResponseDataNodesInnerData 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 variables
        if self.variables:
            _dict['variables'] = self.variables.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "label": obj.get("label"),
            "action": obj.get("action"),
            "isStartNode": obj.get("isStartNode"),
            "staticText": obj.get("staticText"),
            "knowledgeBase": obj.get("knowledgeBase"),
            "useGlobalKnowledgeBase": obj.get("useGlobalKnowledgeBase"),
            "isDisconnected": obj.get("isDisconnected"),
            "type": obj.get("type"),
            "variables": AgentIdWorkflowGet200ResponseDataNodesInnerDataVariables.from_dict(obj["variables"]) if obj.get("variables") is not None else None,
            "hasError": obj.get("hasError"),
            "validationErrors": obj.get("validationErrors"),
            "httpRequest": obj.get("httpRequest"),
            "responseData": obj.get("responseData")
        })
        return _obj


