Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/uipath-platform/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath-platform"
version = "0.1.28"
version = "0.1.29"
description = "HTTP client library for programmatic access to UiPath Platform"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def invoke(
folder_path: Optional[str] = None,
attachments: Optional[list[Attachment]] = None,
parent_operation_id: Optional[str] = None,
run_as_me: Optional[bool] = None,
**kwargs: Any,
) -> Job:
"""Start execution of a process by its name.
Expand All @@ -63,6 +64,7 @@ def invoke(
folder_key (Optional[str]): The key of the folder to execute the process in. Override the default one set in the SDK config.
folder_path (Optional[str]): The path of the folder to execute the process in. Override the default one set in the SDK config.
parent_operation_id (Optional[str]): The parent operation ID for BTS tracking correlation.
run_as_me (Optional[bool]): If True, the job will run under the calling user's identity.

Returns:
Job: The job execution details.
Expand Down Expand Up @@ -100,6 +102,7 @@ def invoke(
folder_path=folder_path,
parent_span_id=kwargs.get("parent_span_id"),
parent_operation_id=parent_operation_id,
run_as_me=run_as_me,
)
response = self.request(
spec.method,
Expand All @@ -123,6 +126,7 @@ async def invoke_async(
folder_path: Optional[str] = None,
attachments: Optional[list[Attachment]] = None,
parent_operation_id: Optional[str] = None,
run_as_me: Optional[bool] = None,
**kwargs: Any,
) -> Job:
"""Asynchronously start execution of a process by its name.
Expand All @@ -136,6 +140,7 @@ async def invoke_async(
folder_key (Optional[str]): The key of the folder to execute the process in. Override the default one set in the SDK config.
folder_path (Optional[str]): The path of the folder to execute the process in. Override the default one set in the SDK config.
parent_operation_id (Optional[str]): The parent operation ID for BTS tracking correlation.
run_as_me (Optional[bool]): If True, the job will run under the calling user's identity.

Returns:
Job: The job execution details.
Expand Down Expand Up @@ -168,6 +173,7 @@ async def main():
folder_path=folder_path,
parent_span_id=kwargs.get("parent_span_id"),
parent_operation_id=parent_operation_id,
run_as_me=run_as_me,
)

response = await self.request_async(
Expand Down Expand Up @@ -313,13 +319,17 @@ def _invoke_spec(
folder_path: Optional[str] = None,
parent_span_id: Optional[str] = None,
parent_operation_id: Optional[str] = None,
run_as_me: Optional[bool] = None,
) -> RequestSpec:
payload: Dict[str, Any] = {"ReleaseName": name, **(input_data or {})}
self._add_tracing(payload, UiPathConfig.trace_id, parent_span_id)

if parent_operation_id:
payload["ParentOperationId"] = parent_operation_id

if run_as_me is not None:
payload["RunAsMe"] = run_as_me

request_spec = RequestSpec(
method="POST",
endpoint=Endpoint(
Expand Down
93 changes: 93 additions & 0 deletions packages/uipath-platform/tests/services/test_processes_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,3 +471,96 @@ async def test_invoke_async_over_10k_limit_input(
job_request.headers[HEADER_USER_AGENT]
== f"UiPath.Python.Sdk/UiPath.Python.Sdk.Activities.ProcessesService.invoke_async/{version}"
)

def test_invoke_with_run_as_me_true(
self,
httpx_mock: HTTPXMock,
service: ProcessesService,
base_url: str,
org: str,
tenant: str,
) -> None:
process_name = "test-process"
httpx_mock.add_response(
url=f"{base_url}{org}{tenant}/orchestrator_/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs",
status_code=200,
json={
"value": [
{
"Key": "test-job-key",
"State": "Running",
"Id": 123,
"FolderKey": "test-folder-key",
}
]
},
)

service.invoke(process_name, run_as_me=True)

sent_request = httpx_mock.get_request()
assert sent_request is not None
payload = json.loads(sent_request.content.decode("utf-8"))
assert payload["startInfo"]["RunAsMe"] is True

def test_invoke_with_run_as_me_false(
self,
httpx_mock: HTTPXMock,
service: ProcessesService,
base_url: str,
org: str,
tenant: str,
) -> None:
process_name = "test-process"
httpx_mock.add_response(
url=f"{base_url}{org}{tenant}/orchestrator_/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs",
status_code=200,
json={
"value": [
{
"Key": "test-job-key",
"State": "Running",
"Id": 123,
"FolderKey": "test-folder-key",
}
]
},
)

service.invoke(process_name, run_as_me=False)

sent_request = httpx_mock.get_request()
assert sent_request is not None
payload = json.loads(sent_request.content.decode("utf-8"))
assert payload["startInfo"]["RunAsMe"] is False

def test_invoke_without_run_as_me_excludes_from_payload(
self,
httpx_mock: HTTPXMock,
service: ProcessesService,
base_url: str,
org: str,
tenant: str,
) -> None:
process_name = "test-process"
httpx_mock.add_response(
url=f"{base_url}{org}{tenant}/orchestrator_/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs",
status_code=200,
json={
"value": [
{
"Key": "test-job-key",
"State": "Running",
"Id": 123,
"FolderKey": "test-folder-key",
}
]
},
)

service.invoke(process_name)

sent_request = httpx_mock.get_request()
assert sent_request is not None
payload = json.loads(sent_request.content.decode("utf-8"))
assert "RunAsMe" not in payload["startInfo"]
2 changes: 1 addition & 1 deletion packages/uipath-platform/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/uipath/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading