| |
|
| |
|
| | This document outlines the API endpoints for managing workflows in PySpur.
|
| |
|
| |
|
| |
|
| |
|
| | **Description**: Creates a new workflow. If no definition is provided, creates a default workflow with an input node. For chatbots, creates a workflow with required input/output fields for handling chat interactions. The workflow name will be made unique if a workflow with the same name already exists.
|
| |
|
| | **URL**: `/wf/`
|
| |
|
| | **Method**: POST
|
| |
|
| | **Request Payload**:
|
| | ```python
|
| | class WorkflowCreateRequestSchema(BaseModel):
|
| | name: str
|
| | description: str = ""
|
| | definition: Optional[WorkflowDefinitionSchema] = None
|
| | ```
|
| |
|
| | Where `WorkflowDefinitionSchema` contains:
|
| | ```python
|
| | class WorkflowDefinitionSchema(BaseModel):
|
| | nodes: List[WorkflowNodeSchema]
|
| | links: List[WorkflowLinkSchema]
|
| | test_inputs: List[Dict[str, Any]] = []
|
| | spur_type: SpurType = SpurType.WORKFLOW
|
| | ```
|
| |
|
| | **Response Schema**:
|
| | ```python
|
| | class WorkflowResponseSchema(BaseModel):
|
| | id: str
|
| | name: str
|
| | description: Optional[str]
|
| | definition: WorkflowDefinitionSchema
|
| | created_at: datetime
|
| | updated_at: datetime
|
| | ```
|
| |
|
| |
|
| |
|
| |
|
| | **Description**: Updates an existing workflow's definition, name, and description. The workflow definition is required for updates. This endpoint allows for modifying the structure and behavior of a workflow.
|
| |
|
| | **URL**: `/wf/{workflow_id}/`
|
| |
|
| | **Method**: PUT
|
| |
|
| | **Parameters**:
|
| | ```python
|
| | workflow_id: str
|
| | ```
|
| |
|
| | **Request Payload**: Same as Create Workflow
|
| |
|
| | **Response Schema**: Same as Create Workflow
|
| |
|
| |
|
| |
|
| | **Description**: Lists all workflows with pagination support, ordered by creation date descending. Only valid workflows that can be properly validated are included in the response.
|
| |
|
| | **URL**: `/wf/`
|
| |
|
| | **Method**: GET
|
| |
|
| | **Query Parameters**:
|
| | ```python
|
| | page: int
|
| | page_size: int
|
| | ```
|
| |
|
| | **Response Schema**:
|
| | ```python
|
| | List[WorkflowResponseSchema]
|
| | ```
|
| |
|
| |
|
| |
|
| | **Description**: Retrieves a specific workflow by its ID, including its complete definition, metadata, and timestamps.
|
| |
|
| | **URL**: `/wf/{workflow_id}/`
|
| |
|
| | **Method**: GET
|
| |
|
| | **Parameters**:
|
| | ```python
|
| | workflow_id: str
|
| | ```
|
| |
|
| | **Response Schema**: Same as Create Workflow
|
| |
|
| |
|
| |
|
| | **Description**: Resets a workflow to its initial state with just an input node. This is useful when you want to start over with a workflow design without deleting and recreating it.
|
| |
|
| | **URL**: `/wf/{workflow_id}/reset/`
|
| |
|
| | **Method**: PUT
|
| |
|
| | **Parameters**:
|
| | ```python
|
| | workflow_id: str
|
| | ```
|
| |
|
| | **Response Schema**: Same as Create Workflow
|
| |
|
| |
|
| |
|
| | **Description**: Deletes a workflow and its associated test files. This operation is permanent and will remove all data related to the workflow, including test files stored in the file system.
|
| |
|
| | **URL**: `/wf/{workflow_id}/`
|
| |
|
| | **Method**: DELETE
|
| |
|
| | **Parameters**:
|
| | ```python
|
| | workflow_id: str
|
| | ```
|
| |
|
| | **Response**: 204 No Content
|
| |
|
| |
|
| |
|
| | **Description**: Creates a copy of an existing workflow with "(Copy)" appended to its name. This is useful for creating variations of a workflow without modifying the original.
|
| |
|
| | **URL**: `/wf/{workflow_id}/duplicate/`
|
| |
|
| | **Method**: POST
|
| |
|
| | **Parameters**:
|
| | ```python
|
| | workflow_id: str
|
| | ```
|
| |
|
| | **Response Schema**: Same as Create Workflow
|
| |
|
| |
|
| |
|
| | **Description**: Retrieves the output variables (leaf nodes) of a workflow, including their node IDs and variable names. This is useful for understanding what outputs are available from a workflow.
|
| |
|
| | **URL**: `/wf/{workflow_id}/output_variables/`
|
| |
|
| | **Method**: GET
|
| |
|
| | **Parameters**:
|
| | ```python
|
| | workflow_id: str
|
| | ```
|
| |
|
| | **Response Schema**:
|
| | ```python
|
| | List[Dict[str, str]]
|
| | ```
|
| |
|
| | Each dictionary in the list contains:
|
| | ```python
|
| | {
|
| | "node_id": str,
|
| | "variable_name": str,
|
| | "prefixed_variable": str
|
| | }
|
| | ```
|
| |
|
| |
|
| |
|
| | **Description**: Uploads test files for a specific node in a workflow and returns their paths. The files are stored in a workflow-specific directory and can be used as inputs for testing the workflow.
|
| |
|
| | **URL**: `/wf/upload_test_files/`
|
| |
|
| | **Method**: POST
|
| |
|
| | **Form Data**:
|
| | ```python
|
| | workflow_id: str
|
| | files: List[UploadFile]
|
| | node_id: str
|
| | ```
|
| |
|
| | **Response Schema**:
|
| | ```python
|
| | Dict[str, List[str]]
|
| | ```
|
| |
|
| | Example:
|
| | ```python
|
| | {
|
| | "node_id": ["test_files/workflow_id/timestamp_filename.ext", ...]
|
| | }
|
| | ```
|
| |
|
| |
|
| |
|
| | **Description**: Retrieves all versions of a workflow, ordered by version number descending, with pagination support. This allows tracking the evolution of a workflow over time and reverting to previous versions if needed.
|
| |
|
| | **URL**: `/wf/{workflow_id}/versions/`
|
| |
|
| | **Method**: GET
|
| |
|
| | **Parameters**:
|
| | ```python
|
| | workflow_id: str
|
| | page: int
|
| | page_size: int
|
| | ```
|
| |
|
| | **Response Schema**:
|
| | ```python
|
| | List[WorkflowVersionResponseSchema]
|
| | ```
|
| |
|
| | Where `WorkflowVersionResponseSchema` contains:
|
| | ```python
|
| | class WorkflowVersionResponseSchema(BaseModel):
|
| | version: int
|
| | name: str
|
| | description: Optional[str]
|
| | definition: Any
|
| | definition_hash: str
|
| | created_at: datetime
|
| | updated_at: datetime
|
| | ```
|
| |
|
| |
|
| |
|
| | **Description**: Lists all workflows that are currently in a paused state, with pagination support. This endpoint is useful for monitoring workflows that require human intervention.
|
| |
|
| | **URL**: `/wf/paused_workflows/`
|
| |
|
| | **Method**: GET
|
| |
|
| | **Query Parameters**:
|
| | ```python
|
| | page: int
|
| | page_size: int
|
| | ```
|
| |
|
| | **Response Schema**:
|
| | ```python
|
| | List[PausedWorkflowResponseSchema]
|
| | ```
|
| |
|
| | Where `PausedWorkflowResponseSchema` contains:
|
| | ```python
|
| | class PausedWorkflowResponseSchema(BaseModel):
|
| | run: RunResponseSchema
|
| | current_pause: PauseHistoryResponseSchema
|
| | workflow: WorkflowDefinitionSchema
|
| | ```
|
| |
|
| |
|
| |
|
| | **Description**: Retrieves the pause history for a specific workflow run, showing when and why the workflow was paused, and any actions taken to resume it.
|
| |
|
| | **URL**: `/wf/pause_history/{run_id}/`
|
| |
|
| | **Method**: GET
|
| |
|
| | **Parameters**:
|
| | ```python
|
| | run_id: str
|
| | ```
|
| |
|
| | **Response Schema**:
|
| | ```python
|
| | List[PauseHistoryResponseSchema]
|
| | ```
|
| |
|
| | Where `PauseHistoryResponseSchema` contains:
|
| | ```python
|
| | class PauseHistoryResponseSchema(BaseModel):
|
| | id: str
|
| | run_id: str
|
| | node_id: str
|
| | pause_message: Optional[str]
|
| | pause_time: datetime
|
| | resume_time: Optional[datetime]
|
| | resume_user_id: Optional[str]
|
| | resume_action: Optional[PauseAction]
|
| | input_data: Optional[Dict[str, Any]]
|
| | comments: Optional[str]
|
| | ```
|
| |
|
| |
|
| |
|
| | **Description**: Processes an action on a paused workflow, allowing for approval, decline, or override of a workflow that has been paused for human intervention. The workflow will resume execution based on the action taken.
|
| |
|
| | **URL**: `/wf/process_pause_action/{run_id}/`
|
| |
|
| | **Method**: POST
|
| |
|
| | **Parameters**:
|
| | ```python
|
| | run_id: str
|
| | ```
|
| |
|
| | **Request Payload**:
|
| | ```python
|
| | class ResumeRunRequestSchema(BaseModel):
|
| | inputs: Dict[str, Any]
|
| | user_id: str
|
| | action: PauseAction
|
| | comments: Optional[str] = None
|
| | ```
|
| |
|
| | **Response Schema**:
|
| | ```python
|
| | class RunResponseSchema(BaseModel):
|
| | id: str
|
| | workflow_id: str
|
| | workflow_version_id: Optional[str]
|
| | workflow_version: Optional[WorkflowVersionResponseSchema]
|
| | status: RunStatus
|
| | start_time: datetime
|
| | end_time: Optional[datetime]
|
| | initial_inputs: Optional[Dict[str, Dict[str, Any]]]
|
| | outputs: Optional[Dict[str, Dict[str, Any]]]
|
| | tasks: List[TaskResponseSchema]
|
| | parent_run_id: Optional[str]
|
| | run_type: str
|
| | output_file_id: Optional[str]
|
| | input_dataset_id: Optional[str]
|
| | message: Optional[str]
|
| | duration: Optional[float]
|
| | percentage_complete: float
|
| | ```
|
| |
|