# generated by datamodel-codegen:
#   filename:  flow.json
#   timestamp: 2026-01-25T13:38:22+00:00

from __future__ import annotations

from enum import StrEnum
from typing import Any

from pydantic import AwareDatetime, BaseModel, ConfigDict


class Type(StrEnum):
    """
    Type of the flow
    """

    flow = 'flow'
    test = 'test'
    performance = 'performance'


class LastResult(StrEnum):
    """
    Result of last execution
    """

    passed = 'passed'
    failed = 'failed'
    pending = 'pending'
    running = 'running'


class Position(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    x: float
    """
    X coordinate
    """
    y: float
    """
    Y coordinate
    """


class ActionData(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    label: str
    """
    Human-readable label
    """
    type: str
    """
    Action type identifier
    """
    config: dict[str, Any]
    """
    Action-specific configuration
    """


class Action(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    """
    Unique action identifier
    """
    type: str
    """
    Action type
    """
    position: Position
    data: ActionData


class Edge(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    """
    Unique edge identifier
    """
    source: str
    """
    Source action ID
    """
    sourceHandle: str | None = None
    """
    Source handle identifier
    """
    target: str
    """
    Target action ID
    """
    targetHandle: str | None = None
    """
    Target handle identifier
    """
    type: str | None = 'step'
    """
    Edge type
    """
    data: dict[str, Any] | None = None
    """
    Additional edge data
    """


class Zoom(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    x: float
    """
    Pan X position
    """
    y: float
    """
    Pan Y position
    """
    zoom: float
    """
    Zoom level
    """


class Variable(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    """
    Variable identifier
    """
    name: str
    """
    Variable name
    """
    type: str
    """
    Variable data type
    """
    value: Any
    """
    Variable value
    """
    description: str | None = None
    """
    Optional description
    """


class FlowVariables(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    input: list[Variable]
    """
    Input variables
    """
    output: list[Variable]
    """
    Output variables
    """


class FlowParameters(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    input: list[Variable]
    """
    Input parameters
    """
    parameterBefore: list[Variable] = []
    """
    Parameters to be set before execution
    """
    variableBefore: list[Variable] = []
    """
    Variables to be set before execution
    """
    output: list[Variable]
    """
    Output parameters
    """


class EnvironmentVariable(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    """
    Variable identifier
    """
    name: str
    """
    Variable name
    """
    type: str
    """
    Variable data type
    """
    value: Any
    """
    Variable value
    """
    description: str | None = None
    """
    Optional description
    """


class Environment(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    """
    Environment identifier
    """
    name: str
    """
    Environment name
    """
    variables: list[EnvironmentVariable | Variable] = None
    """
    Environment variables
    """
    description: str | None = None
    """
    Environment description
    """
    isDefault: bool | None = None
    """
    Whether this is the default environment
    """
    isActive: bool | None = None
    """
    Whether this environment is active
    """
    createdAt: AwareDatetime | None = None
    """
    Creation timestamp
    """
    updatedAt: AwareDatetime | None = None
    """
    Last update timestamp
    """


class GlobalVariable(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    """
    Variable identifier
    """
    name: str
    """
    Variable name
    """
    type: str
    """
    Variable data type
    """
    value: Any
    """
    Variable value
    """
    description: str | None = None
    """
    Optional description
    """


class Flow(BaseModel):
    """
    Complete flow definition for automation workflows
    """

    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    """
    Unique identifier for the flow
    """
    name: str
    """
    Human-readable name of the flow
    """
    description: str | None = None
    """
    Optional description of the flow
    """
    tags: list[str] | None = None
    """
    Tags for categorization and filtering
    """
    parentID: str | None = None
    """
    Parent folder ID for organization
    """
    type: Type | None = Type.flow
    """
    Type of the flow
    """
    actions: list[Action]
    """
    List of actions in the flow
    """
    edges: list[Edge]
    """
    Connections between actions
    """
    zoom: Zoom | None = None
    """
    Canvas zoom and pan state
    """
    createdAt: AwareDatetime | None = None
    """
    Creation timestamp
    """
    updatedAt: AwareDatetime | None = None
    """
    Last update timestamp
    """
    variables: FlowVariables = None
    """
    Flow input and output variables
    """
    parameters: FlowParameters = None
    """
    Flow parameters for configuration
    """
    environment: Environment | None = None
    """
    Environment configuration
    """
    globalVariables: list[GlobalVariable] | None = None
    """
    Global variables available to the flow
    """
    synced: bool | None = None
    """
    Whether the flow is synced with server
    """
    lastRun: AwareDatetime | None = None
    """
    Last execution timestamp
    """
    lastResult: LastResult | None = None
    """
    Result of last execution
    """
