Skip to content

Commit 0bb3af1

Browse files
author
Jens Kürten
committed
Add StartWorkflowAction to ActionUnion and update ActionNames
1 parent c0bd6a2 commit 0bb3af1

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

csfunctions/actions/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
from .abort_and_show_error import AbortAndShowErrorAction
66
from .base import ActionNames
77
from .dummy import DummyAction
8+
from .start_workflow import StartWorkflowAction
89

9-
ActionUnion = Union[AbortAndShowErrorAction, DummyAction]
10+
ActionUnion = Union[AbortAndShowErrorAction, DummyAction, StartWorkflowAction]
1011
Action = Annotated[ActionUnion, Field(discriminator="name")]
1112

1213
__all__ = [
@@ -15,4 +16,5 @@
1516
"DummyAction",
1617
"AbortAndShowErrorAction",
1718
"ActionUnion",
19+
"StartWorkflowAction",
1820
]

csfunctions/actions/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
class ActionNames(str, Enum):
77
ABORT_AND_SHOW_ERROR = "abort_and_show_error"
88
DUMMY = "dummy"
9+
START_WORKFLOW = "start_workflow"
910

1011

1112
class BaseAction(BaseModel):
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from typing import Literal
2+
3+
from pydantic import BaseModel, Field
4+
5+
from .base import ActionNames, BaseAction
6+
7+
8+
class TaskParameter(BaseModel):
9+
task_id: str = Field(..., description="Identifier for the task this parameter belongs to")
10+
name: str = Field(..., description="Name of the parameter")
11+
value: str = Field(..., description="Value of the parameter")
12+
13+
14+
class StartWorkflowAction(BaseAction):
15+
name: Literal[ActionNames.START_WORKFLOW] = ActionNames.START_WORKFLOW
16+
template_id: str = Field(..., description="ID of the workflow template to start")
17+
cdb_project_id: str | None = Field(
18+
default=None, description="ID of the project in which the workflow should be started"
19+
)
20+
title: str = Field(..., description="Title of the workflow")
21+
attachment_ids: list[str] = Field(
22+
default_factory=list, description="List of cdb_object_ids to attach to the workflow"
23+
)
24+
global_briefcase_object_ids: list[str] = Field(
25+
default_factory=list, description="List of cdb_object_ids to attach to the global briefcase"
26+
)
27+
task_parameters: list[TaskParameter] = Field(default_factory=list, description="List of task parameters")

0 commit comments

Comments
 (0)