44
55from uipath .core .triggers import UiPathResumeTrigger
66
7+ from uipath .runtime .errors import UiPathRuntimeError
8+ from uipath .runtime .errors .codes import UiPathErrorCode
79from uipath .runtime .storage import UiPathRuntimeStorageProtocol
810
911
@@ -34,6 +36,20 @@ async def get_triggers(self, runtime_id: str) -> list[UiPathResumeTrigger] | Non
3436 """
3537 ...
3638
39+ async def delete_triggers (
40+ self , runtime_id : str , triggers : list [UiPathResumeTrigger ]
41+ ) -> None :
42+ """Delete resume triggers from storage.
43+
44+ Args:
45+ runtime_id: The runtime ID
46+ triggers: The resume triggers to delete
47+
48+ Raises:
49+ Exception: If deletion operation fails
50+ """
51+ ...
52+
3753 async def delete_trigger (
3854 self , runtime_id : str , trigger : UiPathResumeTrigger
3955 ) -> None :
@@ -46,7 +62,8 @@ async def delete_trigger(
4662 Raises:
4763 Exception: If deletion operation fails
4864 """
49- ...
65+ # TODO: Remove this compatibility alias in the next minor version.
66+ await self .delete_triggers (runtime_id , [trigger ])
5067
5168
5269class UiPathResumeTriggerCreatorProtocol (Protocol ):
@@ -63,6 +80,34 @@ async def create_trigger(self, suspend_value: Any) -> UiPathResumeTrigger:
6380 Returns:
6481 UiPathResumeTrigger ready to be persisted
6582
83+ Raises:
84+ UiPathRuntimeError: If trigger creation fails
85+ """
86+ # TODO: Remove this compatibility alias in the next minor version.
87+ triggers = await self .create_triggers (suspend_value )
88+ if len (triggers ) != 1 :
89+ raise UiPathRuntimeError (
90+ code = UiPathErrorCode .CREATE_RESUME_TRIGGER_ERROR ,
91+ title = "Unexpected resume trigger count" ,
92+ detail = (
93+ "create_trigger() cannot return multiple resume triggers. "
94+ "Use create_triggers() instead."
95+ ),
96+ )
97+ return triggers [0 ]
98+
99+ async def create_triggers (self , suspend_value : Any ) -> list [UiPathResumeTrigger ]:
100+ """Create resume triggers from a suspend value.
101+
102+ Most suspend values produce one trigger. Composite values may produce
103+ multiple sibling triggers for the same interrupt.
104+
105+ Args:
106+ suspend_value: The value that caused the suspension.
107+
108+ Returns:
109+ UiPathResumeTrigger objects ready to be persisted.
110+
66111 Raises:
67112 UiPathRuntimeError: If trigger creation fails
68113 """
0 commit comments