Skip to content

Commit 7f7761e

Browse files
committed
feat: create external trigger entities
1 parent 46d6ff2 commit 7f7761e

File tree

4 files changed

+67
-3
lines changed

4 files changed

+67
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath"
3-
version = "2.6.0"
3+
version = "2.6.1"
44
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

src/uipath/platform/resume_triggers/_enums.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from enum import Enum
44

5+
from pydantic import BaseModel, Field
6+
57

68
class PropertyName(str, Enum):
79
"""UiPath trigger property names."""
@@ -16,3 +18,23 @@ class TriggerMarker(str, Enum):
1618
"""
1719

1820
NO_CONTENT = "NO_CONTENT"
21+
22+
23+
class ExternalTriggerType(str, Enum):
24+
"""External trigger types."""
25+
26+
DEEP_RAG = "deepRag"
27+
BATCH_TRANSFORM = "batchTransform"
28+
IXP_EXTRACTION = "ixpExtraction"
29+
30+
31+
class ExternalTrigger(BaseModel):
32+
"""Model representing an external trigger entity."""
33+
34+
type: ExternalTriggerType
35+
external_id: str = Field(alias="externalId")
36+
37+
model_config = {
38+
"validate_by_name": True,
39+
"validate_by_alias": True,
40+
}

src/uipath/platform/resume_triggers/_protocol.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
CreateTask,
2929
DocumentExtraction,
3030
InvokeProcess,
31+
UiPathConfig,
3132
WaitBatchTransform,
3233
WaitDeepRag,
3334
WaitDocumentExtraction,
@@ -42,7 +43,12 @@
4243
OperationNotCompleteException,
4344
)
4445
from uipath.platform.orchestrator.job import JobState
45-
from uipath.platform.resume_triggers._enums import PropertyName, TriggerMarker
46+
from uipath.platform.resume_triggers._enums import (
47+
ExternalTrigger,
48+
ExternalTriggerType,
49+
PropertyName,
50+
TriggerMarker,
51+
)
4652

4753

4854
def _try_convert_to_json_format(value: str | None) -> Any:
@@ -371,6 +377,19 @@ async def create_trigger(self, suspend_value: Any) -> UiPathResumeTrigger:
371377
) from e
372378
return resume_trigger
373379

380+
async def _create_external_trigger(self, external_trigger: ExternalTrigger):
381+
"""Creates an external trigger in orchestrator."""
382+
# only create external trigger entities for non-debug runs
383+
if not UiPathConfig.job_key:
384+
return
385+
386+
uipath = UiPath()
387+
await uipath.api_client.request_async(
388+
method="POST",
389+
url="orchestrator_/api/JobTriggers/SaveExternalTrigger",
390+
json=external_trigger.model_dump(by_alias=True),
391+
)
392+
374393
def _determine_trigger_type(self, value: Any) -> UiPathResumeTriggerType:
375394
"""Determines the resume trigger type based on the input value.
376395
@@ -477,6 +496,13 @@ async def _handle_deep_rag_job_trigger(
477496
)
478497
if not deep_rag:
479498
raise Exception("Failed to start deep rag")
499+
500+
await self._create_external_trigger(
501+
ExternalTrigger(
502+
type=ExternalTriggerType.DEEP_RAG, external_id=deep_rag.id
503+
)
504+
)
505+
480506
resume_trigger.item_key = deep_rag.id
481507

482508
async def _handle_batch_rag_job_trigger(
@@ -506,6 +532,14 @@ async def _handle_batch_rag_job_trigger(
506532
)
507533
if not batch_transform:
508534
raise Exception("Failed to start batch transform")
535+
536+
await self._create_external_trigger(
537+
ExternalTrigger(
538+
type=ExternalTriggerType.BATCH_TRANSFORM,
539+
external_id=batch_transform.id,
540+
)
541+
)
542+
509543
resume_trigger.item_key = batch_transform.id
510544

511545
async def _handle_ixp_extraction_trigger(
@@ -531,6 +565,14 @@ async def _handle_ixp_extraction_trigger(
531565
)
532566
if not document_extraction:
533567
raise Exception("Failed to start document extraction")
568+
569+
await self._create_external_trigger(
570+
ExternalTrigger(
571+
type=ExternalTriggerType.IXP_EXTRACTION,
572+
external_id=document_extraction.operation_id,
573+
)
574+
)
575+
534576
resume_trigger.item_key = document_extraction.operation_id
535577

536578
# add project_id and tag to the payload dict (needed when reading the trigger)

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)