"""Workflow resource for the Daly Energy SDK.

Workflows are parent tasks that orchestrate a chain of child tasks
(e.g., parse file -> run shading -> update results).
"""

from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from dalysdk.client import DalyClient


class WorkflowResource:
    """Interact with the ``/workflows`` endpoints.

    Usage::

        workflow = client.workflows.get(1)
        # Returns {"workflow": {...}, "tasks": [...]}
    """

    def __init__(self, client: DalyClient):
        self._client = client

    def get(self, workflow_id: int) -> dict:
        """Get a workflow and all its child tasks.

        Args:
            workflow_id: Workspace-scoped workflow (parent task) index.

        Returns:
            Dict with ``workflow`` (parent task dict) and ``tasks``
            (list of child task dicts ordered by chain position).

        Raises:
            NotFoundError: If the workflow does not exist.
        """
        return self._client._request("GET", f"/workflows/{workflow_id}")
