# coding: utf-8

"""
    Agent Service

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: v1
    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, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from asteroid_odyssey.models.agents_graph_models_agent_graph import AgentsGraphModelsAgentGraph
from asteroid_odyssey.models.agents_graph_models_settings import AgentsGraphModelsSettings
from asteroid_odyssey.models.agents_workflow_environment_template import AgentsWorkflowEnvironmentTemplate
from typing import Optional, Set
from typing_extensions import Self

class AgentsWorkflowWorkflowSnapshot(BaseModel):
    """
    A workflow (commit) representing an immutable snapshot of agent configuration
    """ # noqa: E501
    id: StrictStr = Field(description="The unique ID of this workflow")
    agent_id: StrictStr = Field(description="The agent ID this workflow belongs to", alias="agentId")
    parent_id: Optional[StrictStr] = Field(default=None, description="The ID of the parent workflow this was derived from (for lineage tracking)", alias="parentId")
    version: Optional[StrictInt] = Field(default=None, description="The published version number. Null if unpublished.")
    rules: StrictStr = Field(description="The rules/instructions for this workflow")
    settings: AgentsGraphModelsSettings = Field(description="The settings for this workflow")
    task: Optional[StrictStr] = Field(default=None, description="The task description")
    inputs: List[StrictStr] = Field(description="Input placeholders for workflow execution")
    graph: AgentsGraphModelsAgentGraph = Field(description="The workflow graph")
    created_at: datetime = Field(description="When this workflow was created", alias="createdAt")
    author: Optional[StrictStr] = Field(default=None, description="The email of the user who created this workflow.")
    environment_template: Optional[AgentsWorkflowEnvironmentTemplate] = Field(default=None, description="Optional environment template. Defaults to browser/anchor if not provided.", alias="environmentTemplate")
    __properties: ClassVar[List[str]] = ["id", "agentId", "parentId", "version", "rules", "settings", "task", "inputs", "graph", "createdAt", "author", "environmentTemplate"]

    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 AgentsWorkflowWorkflowSnapshot 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 settings
        if self.settings:
            _dict['settings'] = self.settings.to_dict()
        # override the default output from pydantic by calling `to_dict()` of graph
        if self.graph:
            _dict['graph'] = self.graph.to_dict()
        # override the default output from pydantic by calling `to_dict()` of environment_template
        if self.environment_template:
            _dict['environmentTemplate'] = self.environment_template.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of AgentsWorkflowWorkflowSnapshot 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"),
            "agentId": obj.get("agentId"),
            "parentId": obj.get("parentId"),
            "version": obj.get("version"),
            "rules": obj.get("rules"),
            "settings": AgentsGraphModelsSettings.from_dict(obj["settings"]) if obj.get("settings") is not None else None,
            "task": obj.get("task"),
            "inputs": obj.get("inputs"),
            "graph": AgentsGraphModelsAgentGraph.from_dict(obj["graph"]) if obj.get("graph") is not None else None,
            "createdAt": obj.get("createdAt"),
            "author": obj.get("author"),
            "environmentTemplate": AgentsWorkflowEnvironmentTemplate.from_dict(obj["environmentTemplate"]) if obj.get("environmentTemplate") is not None else None
        })
        return _obj


