uipath 2.0.0.dev3__py3-none-any.whl → 2.0.1.dev1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of uipath might be problematic. Click here for more details.
- uipath/__init__.py +24 -0
- uipath/_cli/README.md +11 -0
- uipath/_cli/__init__.py +54 -0
- uipath/_cli/_auth/_auth_server.py +165 -0
- uipath/_cli/_auth/_models.py +51 -0
- uipath/_cli/_auth/_oidc_utils.py +69 -0
- uipath/_cli/_auth/_portal_service.py +163 -0
- uipath/_cli/_auth/_utils.py +51 -0
- uipath/_cli/_auth/auth_config.json +6 -0
- uipath/_cli/_auth/index.html +167 -0
- uipath/_cli/_auth/localhost.crt +25 -0
- uipath/_cli/_auth/localhost.key +27 -0
- uipath/_cli/_runtime/_contracts.py +429 -0
- uipath/_cli/_runtime/_logging.py +193 -0
- uipath/_cli/_runtime/_runtime.py +264 -0
- uipath/_cli/_templates/.psmdcp.template +9 -0
- uipath/_cli/_templates/.rels.template +5 -0
- uipath/_cli/_templates/[Content_Types].xml.template +9 -0
- uipath/_cli/_templates/main.py.template +25 -0
- uipath/_cli/_templates/package.nuspec.template +10 -0
- uipath/_cli/_utils/_common.py +24 -0
- uipath/_cli/_utils/_input_args.py +126 -0
- uipath/_cli/_utils/_parse_ast.py +542 -0
- uipath/_cli/cli_auth.py +97 -0
- uipath/_cli/cli_deploy.py +13 -0
- uipath/_cli/cli_init.py +113 -0
- uipath/_cli/cli_new.py +76 -0
- uipath/_cli/cli_pack.py +337 -0
- uipath/_cli/cli_publish.py +113 -0
- uipath/_cli/cli_run.py +133 -0
- uipath/_cli/middlewares.py +113 -0
- uipath/_config.py +6 -0
- uipath/_execution_context.py +83 -0
- uipath/_folder_context.py +62 -0
- uipath/_models/__init__.py +37 -0
- uipath/_models/action_schema.py +26 -0
- uipath/_models/actions.py +64 -0
- uipath/_models/assets.py +48 -0
- uipath/_models/connections.py +51 -0
- uipath/_models/context_grounding.py +18 -0
- uipath/_models/context_grounding_index.py +60 -0
- uipath/_models/exceptions.py +6 -0
- uipath/_models/interrupt_models.py +28 -0
- uipath/_models/job.py +66 -0
- uipath/_models/llm_gateway.py +101 -0
- uipath/_models/processes.py +48 -0
- uipath/_models/queues.py +167 -0
- uipath/_services/__init__.py +26 -0
- uipath/_services/_base_service.py +250 -0
- uipath/_services/actions_service.py +271 -0
- uipath/_services/api_client.py +89 -0
- uipath/_services/assets_service.py +257 -0
- uipath/_services/buckets_service.py +268 -0
- uipath/_services/connections_service.py +185 -0
- uipath/_services/connections_service.pyi +50 -0
- uipath/_services/context_grounding_service.py +402 -0
- uipath/_services/folder_service.py +49 -0
- uipath/_services/jobs_service.py +265 -0
- uipath/_services/llm_gateway_service.py +311 -0
- uipath/_services/processes_service.py +168 -0
- uipath/_services/queues_service.py +314 -0
- uipath/_uipath.py +98 -0
- uipath/_utils/__init__.py +17 -0
- uipath/_utils/_endpoint.py +79 -0
- uipath/_utils/_infer_bindings.py +30 -0
- uipath/_utils/_logs.py +15 -0
- uipath/_utils/_request_override.py +18 -0
- uipath/_utils/_request_spec.py +23 -0
- uipath/_utils/_user_agent.py +16 -0
- uipath/_utils/constants.py +25 -0
- uipath/py.typed +0 -0
- {uipath-2.0.0.dev3.dist-info → uipath-2.0.1.dev1.dist-info}/METADATA +2 -3
- uipath-2.0.1.dev1.dist-info/RECORD +75 -0
- uipath-2.0.0.dev3.dist-info/RECORD +0 -4
- {uipath-2.0.0.dev3.dist-info → uipath-2.0.1.dev1.dist-info}/WHEEL +0 -0
- {uipath-2.0.0.dev3.dist-info → uipath-2.0.1.dev1.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
from typing import Any, Dict, Optional
|
|
4
|
+
|
|
5
|
+
from .._config import Config
|
|
6
|
+
from .._execution_context import ExecutionContext
|
|
7
|
+
from .._folder_context import FolderContext
|
|
8
|
+
from .._models.job import Job
|
|
9
|
+
from .._utils import Endpoint, RequestSpec, header_folder, infer_bindings
|
|
10
|
+
from .._utils.constants import ENV_JOB_ID, HEADER_JOB_KEY
|
|
11
|
+
from ._base_service import BaseService
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ProcessesService(FolderContext, BaseService):
|
|
15
|
+
"""Service for managing and executing UiPath automation processes.
|
|
16
|
+
|
|
17
|
+
Processes (also known as automations or workflows) are the core units of
|
|
18
|
+
automation in UiPath, representing sequences of activities that perform
|
|
19
|
+
specific business tasks.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(self, config: Config, execution_context: ExecutionContext) -> None:
|
|
23
|
+
super().__init__(config=config, execution_context=execution_context)
|
|
24
|
+
|
|
25
|
+
def invoke(
|
|
26
|
+
self,
|
|
27
|
+
name: str,
|
|
28
|
+
input_arguments: Optional[Dict[str, Any]] = None,
|
|
29
|
+
*,
|
|
30
|
+
folder_key: Optional[str] = None,
|
|
31
|
+
folder_path: Optional[str] = None,
|
|
32
|
+
) -> Job:
|
|
33
|
+
"""Start execution of a process by its name.
|
|
34
|
+
|
|
35
|
+
Related Activity: [Invoke Process](https://docs.uipath.com/activities/other/latest/workflow/invoke-process)
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
name (str): The name of the process to execute.
|
|
39
|
+
input_arguments (Optional[Dict[str, Any]]): The input arguments to pass to the process.
|
|
40
|
+
folder_key (Optional[str]): The key of the folder to execute the process in. Override the default one set in the SDK config.
|
|
41
|
+
folder_path (Optional[str]): The path of the folder to execute the process in. Override the default one set in the SDK config.
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
Job: The job execution details.
|
|
45
|
+
|
|
46
|
+
Examples:
|
|
47
|
+
```python
|
|
48
|
+
from uipath import UiPath
|
|
49
|
+
|
|
50
|
+
client = UiPath()
|
|
51
|
+
|
|
52
|
+
client.processes.invoke(name="MyProcess")
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
# if you want to execute the process in a specific folder
|
|
57
|
+
# another one than the one set in the SDK config
|
|
58
|
+
from uipath import UiPath
|
|
59
|
+
|
|
60
|
+
client = UiPath()
|
|
61
|
+
|
|
62
|
+
client.processes.invoke(name="MyProcess", folder_path="my-folder-key")
|
|
63
|
+
```
|
|
64
|
+
"""
|
|
65
|
+
spec = self._invoke_spec(
|
|
66
|
+
name,
|
|
67
|
+
input_arguments=input_arguments,
|
|
68
|
+
folder_key=folder_key,
|
|
69
|
+
folder_path=folder_path,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
response = self.request(
|
|
73
|
+
spec.method,
|
|
74
|
+
url=spec.endpoint,
|
|
75
|
+
content=spec.content,
|
|
76
|
+
headers=spec.headers,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
return Job.model_validate(response.json()["value"][0])
|
|
80
|
+
|
|
81
|
+
@infer_bindings()
|
|
82
|
+
async def invoke_async(
|
|
83
|
+
self,
|
|
84
|
+
name: str,
|
|
85
|
+
input_arguments: Optional[Dict[str, Any]] = None,
|
|
86
|
+
*,
|
|
87
|
+
folder_key: Optional[str] = None,
|
|
88
|
+
folder_path: Optional[str] = None,
|
|
89
|
+
) -> Job:
|
|
90
|
+
"""Asynchronously start execution of a process by its name.
|
|
91
|
+
|
|
92
|
+
Related Activity: [Invoke Process](https://docs.uipath.com/activities/other/latest/workflow/invoke-process)
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
name (str): The name of the process to execute.
|
|
96
|
+
input_arguments (Optional[Dict[str, Any]]): The input arguments to pass to the process.
|
|
97
|
+
folder_key (Optional[str]): The key of the folder to execute the process in. Override the default one set in the SDK config.
|
|
98
|
+
folder_path (Optional[str]): The path of the folder to execute the process in. Override the default one set in the SDK config.
|
|
99
|
+
|
|
100
|
+
Returns:
|
|
101
|
+
Job: The job execution details.
|
|
102
|
+
|
|
103
|
+
Examples:
|
|
104
|
+
```python
|
|
105
|
+
import asyncio
|
|
106
|
+
|
|
107
|
+
from uipath import UiPath
|
|
108
|
+
|
|
109
|
+
sdk = UiPath()
|
|
110
|
+
|
|
111
|
+
async def main():
|
|
112
|
+
job = await sdk.processes.invoke_async("testAppAction")
|
|
113
|
+
print(job)
|
|
114
|
+
|
|
115
|
+
asyncio.run(main())
|
|
116
|
+
```
|
|
117
|
+
"""
|
|
118
|
+
spec = self._invoke_spec(
|
|
119
|
+
name,
|
|
120
|
+
input_arguments=input_arguments,
|
|
121
|
+
folder_key=folder_key,
|
|
122
|
+
folder_path=folder_path,
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
response = await self.request_async(
|
|
126
|
+
spec.method,
|
|
127
|
+
url=spec.endpoint,
|
|
128
|
+
content=spec.content,
|
|
129
|
+
headers=spec.headers,
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
return Job.model_validate(response.json()["value"][0])
|
|
133
|
+
|
|
134
|
+
@property
|
|
135
|
+
def custom_headers(self) -> Dict[str, str]:
|
|
136
|
+
return self.folder_headers
|
|
137
|
+
|
|
138
|
+
def _invoke_spec(
|
|
139
|
+
self,
|
|
140
|
+
name: str,
|
|
141
|
+
input_arguments: Optional[Dict[str, Any]] = None,
|
|
142
|
+
*,
|
|
143
|
+
folder_key: Optional[str] = None,
|
|
144
|
+
folder_path: Optional[str] = None,
|
|
145
|
+
) -> RequestSpec:
|
|
146
|
+
request_scope = RequestSpec(
|
|
147
|
+
method="POST",
|
|
148
|
+
endpoint=Endpoint(
|
|
149
|
+
"/orchestrator_/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs"
|
|
150
|
+
),
|
|
151
|
+
content=str(
|
|
152
|
+
{
|
|
153
|
+
"startInfo": {
|
|
154
|
+
"ReleaseName": name,
|
|
155
|
+
"InputArguments": json.dumps(input_arguments)
|
|
156
|
+
if input_arguments
|
|
157
|
+
else "{}",
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
),
|
|
161
|
+
headers={
|
|
162
|
+
**header_folder(folder_key, folder_path),
|
|
163
|
+
},
|
|
164
|
+
)
|
|
165
|
+
job_key = os.environ.get(ENV_JOB_ID, None)
|
|
166
|
+
if job_key:
|
|
167
|
+
request_scope.headers[HEADER_JOB_KEY] = job_key
|
|
168
|
+
return request_scope
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
from typing import Any, Dict, List, Union
|
|
2
|
+
|
|
3
|
+
from httpx import Response
|
|
4
|
+
|
|
5
|
+
from .._config import Config
|
|
6
|
+
from .._execution_context import ExecutionContext
|
|
7
|
+
from .._folder_context import FolderContext
|
|
8
|
+
from .._models import CommitType, QueueItem, TransactionItem, TransactionItemResult
|
|
9
|
+
from .._utils import Endpoint, RequestSpec
|
|
10
|
+
from ._base_service import BaseService
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class QueuesService(FolderContext, BaseService):
|
|
14
|
+
"""Service for managing UiPath queues and queue items.
|
|
15
|
+
|
|
16
|
+
Queues are a fundamental component of UiPath automation that enable distributed
|
|
17
|
+
and scalable processing of work items.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
def __init__(self, config: Config, execution_context: ExecutionContext) -> None:
|
|
21
|
+
super().__init__(config=config, execution_context=execution_context)
|
|
22
|
+
|
|
23
|
+
def list_items(self) -> Response:
|
|
24
|
+
"""Retrieves a list of queue items from the Orchestrator.
|
|
25
|
+
|
|
26
|
+
Returns:
|
|
27
|
+
Response: HTTP response containing the list of queue items.
|
|
28
|
+
"""
|
|
29
|
+
spec = self._list_items_spec()
|
|
30
|
+
return self.request(spec.method, url=spec.endpoint)
|
|
31
|
+
|
|
32
|
+
async def list_items_async(self) -> Response:
|
|
33
|
+
"""Asynchronously retrieves a list of queue items from the Orchestrator.
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
Response: HTTP response containing the list of queue items.
|
|
37
|
+
"""
|
|
38
|
+
spec = self._list_items_spec()
|
|
39
|
+
return await self.request_async(spec.method, url=spec.endpoint)
|
|
40
|
+
|
|
41
|
+
def create_item(self, item: Union[Dict[str, Any], QueueItem]) -> Response:
|
|
42
|
+
"""Creates a new queue item in the Orchestrator.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
item: Queue item data, either as a dictionary or QueueItem instance.
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
Response: HTTP response containing the created queue item details.
|
|
49
|
+
|
|
50
|
+
Related Activity: [Add Queue Item](https://docs.uipath.com/ACTIVITIES/other/latest/workflow/add-queue-item)
|
|
51
|
+
"""
|
|
52
|
+
spec = self._create_item_spec(item)
|
|
53
|
+
return self.request(spec.method, url=spec.endpoint, json=spec.json)
|
|
54
|
+
|
|
55
|
+
async def create_item_async(
|
|
56
|
+
self, item: Union[Dict[str, Any], QueueItem]
|
|
57
|
+
) -> Response:
|
|
58
|
+
"""Asynchronously creates a new queue item in the Orchestrator.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
item: Queue item data, either as a dictionary or QueueItem instance.
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
Response: HTTP response containing the created queue item details.
|
|
65
|
+
|
|
66
|
+
Related Activity: [Add Queue Item](https://docs.uipath.com/ACTIVITIES/other/latest/workflow/add-queue-item)
|
|
67
|
+
"""
|
|
68
|
+
spec = self._create_item_spec(item)
|
|
69
|
+
return await self.request_async(spec.method, url=spec.endpoint, json=spec.json)
|
|
70
|
+
|
|
71
|
+
def create_items(
|
|
72
|
+
self,
|
|
73
|
+
items: List[Union[Dict[str, Any], QueueItem]],
|
|
74
|
+
queue_name: str,
|
|
75
|
+
commit_type: CommitType,
|
|
76
|
+
) -> Response:
|
|
77
|
+
"""Creates multiple queue items in bulk.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
items: List of queue items to create, each either a dictionary or QueueItem instance.
|
|
81
|
+
queue_name: Name of the target queue.
|
|
82
|
+
commit_type: Type of commit operation to use for the bulk operation.
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
Response: HTTP response containing the bulk operation result.
|
|
86
|
+
"""
|
|
87
|
+
spec = self._create_items_spec(items, queue_name, commit_type)
|
|
88
|
+
return self.request(spec.method, url=spec.endpoint, json=spec.json)
|
|
89
|
+
|
|
90
|
+
async def create_items_async(
|
|
91
|
+
self,
|
|
92
|
+
items: List[Union[Dict[str, Any], QueueItem]],
|
|
93
|
+
queue_name: str,
|
|
94
|
+
commit_type: CommitType,
|
|
95
|
+
) -> Response:
|
|
96
|
+
"""Asynchronously creates multiple queue items in bulk.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
items: List of queue items to create, each either a dictionary or QueueItem instance.
|
|
100
|
+
queue_name: Name of the target queue.
|
|
101
|
+
commit_type: Type of commit operation to use for the bulk operation.
|
|
102
|
+
|
|
103
|
+
Returns:
|
|
104
|
+
Response: HTTP response containing the bulk operation result.
|
|
105
|
+
"""
|
|
106
|
+
spec = self._create_items_spec(items, queue_name, commit_type)
|
|
107
|
+
return await self.request_async(spec.method, url=spec.endpoint, json=spec.json)
|
|
108
|
+
|
|
109
|
+
def create_transaction_item(
|
|
110
|
+
self, item: Union[Dict[str, Any], TransactionItem], no_robot: bool = False
|
|
111
|
+
) -> Response:
|
|
112
|
+
"""Creates a new transaction item in a queue.
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
item: Transaction item data, either as a dictionary or TransactionItem instance.
|
|
116
|
+
no_robot: If True, the transaction will not be associated with a robot. Defaults to False.
|
|
117
|
+
|
|
118
|
+
Returns:
|
|
119
|
+
Response: HTTP response containing the transaction item details.
|
|
120
|
+
"""
|
|
121
|
+
spec = self._create_transaction_item_spec(item, no_robot)
|
|
122
|
+
return self.request(spec.method, url=spec.endpoint, json=spec.json)
|
|
123
|
+
|
|
124
|
+
async def create_transaction_item_async(
|
|
125
|
+
self, item: Union[Dict[str, Any], TransactionItem], no_robot: bool = False
|
|
126
|
+
) -> Response:
|
|
127
|
+
"""Asynchronously creates a new transaction item in a queue.
|
|
128
|
+
|
|
129
|
+
Args:
|
|
130
|
+
item: Transaction item data, either as a dictionary or TransactionItem instance.
|
|
131
|
+
no_robot: If True, the transaction will not be associated with a robot. Defaults to False.
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
Response: HTTP response containing the transaction item details.
|
|
135
|
+
"""
|
|
136
|
+
spec = self._create_transaction_item_spec(item, no_robot)
|
|
137
|
+
return await self.request_async(spec.method, url=spec.endpoint, json=spec.json)
|
|
138
|
+
|
|
139
|
+
def update_progress_of_transaction_item(
|
|
140
|
+
self, transaction_key: str, progress: str
|
|
141
|
+
) -> Response:
|
|
142
|
+
"""Updates the progress of a transaction item.
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
transaction_key: Unique identifier of the transaction.
|
|
146
|
+
progress: Progress message to set.
|
|
147
|
+
|
|
148
|
+
Returns:
|
|
149
|
+
Response: HTTP response confirming the progress update.
|
|
150
|
+
|
|
151
|
+
Related Activity: [Set Transaction Progress](https://docs.uipath.com/activities/other/latest/workflow/set-transaction-progress)
|
|
152
|
+
"""
|
|
153
|
+
spec = self._update_progress_of_transaction_item_spec(transaction_key, progress)
|
|
154
|
+
return self.request(spec.method, url=spec.endpoint, json=spec.json)
|
|
155
|
+
|
|
156
|
+
async def update_progress_of_transaction_item_async(
|
|
157
|
+
self, transaction_key: str, progress: str
|
|
158
|
+
) -> Response:
|
|
159
|
+
"""Asynchronously updates the progress of a transaction item.
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
transaction_key: Unique identifier of the transaction.
|
|
163
|
+
progress: Progress message to set.
|
|
164
|
+
|
|
165
|
+
Returns:
|
|
166
|
+
Response: HTTP response confirming the progress update.
|
|
167
|
+
|
|
168
|
+
Related Activity: [Set Transaction Progress](https://docs.uipath.com/activities/other/latest/workflow/set-transaction-progress)
|
|
169
|
+
"""
|
|
170
|
+
spec = self._update_progress_of_transaction_item_spec(transaction_key, progress)
|
|
171
|
+
return await self.request_async(spec.method, url=spec.endpoint, json=spec.json)
|
|
172
|
+
|
|
173
|
+
def complete_transaction_item(
|
|
174
|
+
self, transaction_key: str, result: Union[Dict[str, Any], TransactionItemResult]
|
|
175
|
+
) -> Response:
|
|
176
|
+
"""Completes a transaction item with the specified result.
|
|
177
|
+
|
|
178
|
+
Args:
|
|
179
|
+
transaction_key: Unique identifier of the transaction to complete.
|
|
180
|
+
result: Result data for the transaction, either as a dictionary or TransactionItemResult instance.
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
Response: HTTP response confirming the transaction completion.
|
|
184
|
+
|
|
185
|
+
Related Activity: [Set Transaction Status](https://docs.uipath.com/activities/other/latest/workflow/set-transaction-status)
|
|
186
|
+
"""
|
|
187
|
+
spec = self._complete_transaction_item_spec(transaction_key, result)
|
|
188
|
+
return self.request(spec.method, url=spec.endpoint, json=spec.json)
|
|
189
|
+
|
|
190
|
+
async def complete_transaction_item_async(
|
|
191
|
+
self, transaction_key: str, result: Union[Dict[str, Any], TransactionItemResult]
|
|
192
|
+
) -> Response:
|
|
193
|
+
"""Asynchronously completes a transaction item with the specified result.
|
|
194
|
+
|
|
195
|
+
Args:
|
|
196
|
+
transaction_key: Unique identifier of the transaction to complete.
|
|
197
|
+
result: Result data for the transaction, either as a dictionary or TransactionItemResult instance.
|
|
198
|
+
|
|
199
|
+
Returns:
|
|
200
|
+
Response: HTTP response confirming the transaction completion.
|
|
201
|
+
|
|
202
|
+
Related Activity: [Set Transaction Status](https://docs.uipath.com/activities/other/latest/workflow/set-transaction-status)
|
|
203
|
+
"""
|
|
204
|
+
spec = self._complete_transaction_item_spec(transaction_key, result)
|
|
205
|
+
return await self.request_async(spec.method, url=spec.endpoint, json=spec.json)
|
|
206
|
+
|
|
207
|
+
@property
|
|
208
|
+
def custom_headers(self) -> Dict[str, str]:
|
|
209
|
+
return self.folder_headers
|
|
210
|
+
|
|
211
|
+
def _list_items_spec(self) -> RequestSpec:
|
|
212
|
+
return RequestSpec(
|
|
213
|
+
method="GET",
|
|
214
|
+
endpoint=Endpoint(
|
|
215
|
+
"/orchestrator_/odata/Queues/UiPathODataSvc.GetQueueItems"
|
|
216
|
+
),
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
def _create_item_spec(self, item: Union[Dict[str, Any], QueueItem]) -> RequestSpec:
|
|
220
|
+
if isinstance(item, dict):
|
|
221
|
+
queue_item = QueueItem(**item)
|
|
222
|
+
elif isinstance(item, QueueItem):
|
|
223
|
+
queue_item = item
|
|
224
|
+
|
|
225
|
+
json_payload = {
|
|
226
|
+
"itemData": queue_item.model_dump(exclude_unset=True, by_alias=True)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return RequestSpec(
|
|
230
|
+
method="POST",
|
|
231
|
+
endpoint=Endpoint(
|
|
232
|
+
"/orchestrator_/odata/Queues/UiPathODataSvc.AddQueueItem"
|
|
233
|
+
),
|
|
234
|
+
json=json_payload,
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
def _create_items_spec(
|
|
238
|
+
self,
|
|
239
|
+
items: List[Union[Dict[str, Any], QueueItem]],
|
|
240
|
+
queue_name: str,
|
|
241
|
+
commit_type: CommitType,
|
|
242
|
+
) -> RequestSpec:
|
|
243
|
+
return RequestSpec(
|
|
244
|
+
method="POST",
|
|
245
|
+
endpoint=Endpoint(
|
|
246
|
+
"/orchestrator_/odata/Queues/UiPathODataSvc.BulkAddQueueItems"
|
|
247
|
+
),
|
|
248
|
+
json={
|
|
249
|
+
"queueName": queue_name,
|
|
250
|
+
"commitType": commit_type.value,
|
|
251
|
+
"queueItems": [
|
|
252
|
+
item.model_dump(exclude_unset=True, by_alias=True)
|
|
253
|
+
if isinstance(item, QueueItem)
|
|
254
|
+
else QueueItem(**item).model_dump(exclude_unset=True, by_alias=True)
|
|
255
|
+
for item in items
|
|
256
|
+
],
|
|
257
|
+
},
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
def _create_transaction_item_spec(
|
|
261
|
+
self, item: Union[Dict[str, Any], TransactionItem], no_robot: bool = False
|
|
262
|
+
) -> RequestSpec:
|
|
263
|
+
if isinstance(item, dict):
|
|
264
|
+
transaction_item = TransactionItem(**item)
|
|
265
|
+
elif isinstance(item, TransactionItem):
|
|
266
|
+
transaction_item = item
|
|
267
|
+
|
|
268
|
+
return RequestSpec(
|
|
269
|
+
method="POST",
|
|
270
|
+
endpoint=Endpoint(
|
|
271
|
+
"/orchestrator_/odata/Queues/UiPathODataSvc.StartTransaction"
|
|
272
|
+
),
|
|
273
|
+
json={
|
|
274
|
+
"transactionData": {
|
|
275
|
+
**transaction_item.model_dump(exclude_unset=True, by_alias=True),
|
|
276
|
+
**(
|
|
277
|
+
{"RobotIdentifier": self._execution_context.robot_key}
|
|
278
|
+
if not no_robot
|
|
279
|
+
else {}
|
|
280
|
+
),
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
def _update_progress_of_transaction_item_spec(
|
|
286
|
+
self, transaction_key: str, progress: str
|
|
287
|
+
) -> RequestSpec:
|
|
288
|
+
return RequestSpec(
|
|
289
|
+
method="POST",
|
|
290
|
+
endpoint=Endpoint(
|
|
291
|
+
f"/orchestrator_/odata/QueueItems({transaction_key})/UiPathODataSvc.SetTransactionProgress"
|
|
292
|
+
),
|
|
293
|
+
json={"progress": progress},
|
|
294
|
+
)
|
|
295
|
+
|
|
296
|
+
def _complete_transaction_item_spec(
|
|
297
|
+
self, transaction_key: str, result: Union[Dict[str, Any], TransactionItemResult]
|
|
298
|
+
) -> RequestSpec:
|
|
299
|
+
if isinstance(result, dict):
|
|
300
|
+
transaction_result = TransactionItemResult(**result)
|
|
301
|
+
elif isinstance(result, TransactionItemResult):
|
|
302
|
+
transaction_result = result
|
|
303
|
+
|
|
304
|
+
return RequestSpec(
|
|
305
|
+
method="POST",
|
|
306
|
+
endpoint=Endpoint(
|
|
307
|
+
f"/orchestrator_/odata/Queues({transaction_key})/UiPathODataSvc.SetTransactionResult"
|
|
308
|
+
),
|
|
309
|
+
json={
|
|
310
|
+
"transactionResult": transaction_result.model_dump(
|
|
311
|
+
exclude_unset=True, by_alias=True
|
|
312
|
+
)
|
|
313
|
+
},
|
|
314
|
+
)
|
uipath/_uipath.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
from os import environ as env
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
from dotenv import load_dotenv
|
|
5
|
+
|
|
6
|
+
from ._config import Config
|
|
7
|
+
from ._execution_context import ExecutionContext
|
|
8
|
+
from ._services import (
|
|
9
|
+
ActionsService,
|
|
10
|
+
ApiClient,
|
|
11
|
+
AssetsService,
|
|
12
|
+
BucketsService,
|
|
13
|
+
ConnectionsService,
|
|
14
|
+
ContextGroundingService,
|
|
15
|
+
FolderService,
|
|
16
|
+
JobsService,
|
|
17
|
+
ProcessesService,
|
|
18
|
+
QueuesService,
|
|
19
|
+
)
|
|
20
|
+
from ._utils import setup_logging
|
|
21
|
+
from ._utils.constants import (
|
|
22
|
+
ENV_BASE_URL,
|
|
23
|
+
ENV_UIPATH_ACCESS_TOKEN,
|
|
24
|
+
ENV_UNATTENDED_USER_ACCESS_TOKEN,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
load_dotenv()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class UiPath:
|
|
31
|
+
def __init__(
|
|
32
|
+
self,
|
|
33
|
+
*,
|
|
34
|
+
base_url: Optional[str] = None,
|
|
35
|
+
secret: Optional[str] = None,
|
|
36
|
+
debug: bool = False,
|
|
37
|
+
) -> None:
|
|
38
|
+
base_url_value = base_url or env.get(ENV_BASE_URL)
|
|
39
|
+
secret_value = (
|
|
40
|
+
secret
|
|
41
|
+
or env.get(ENV_UNATTENDED_USER_ACCESS_TOKEN)
|
|
42
|
+
or env.get(ENV_UIPATH_ACCESS_TOKEN)
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
self._config = Config(
|
|
46
|
+
base_url=base_url_value, # type: ignore
|
|
47
|
+
secret=secret_value, # type: ignore
|
|
48
|
+
)
|
|
49
|
+
self._folders_service: Optional[FolderService] = None
|
|
50
|
+
|
|
51
|
+
setup_logging(debug)
|
|
52
|
+
self._execution_context = ExecutionContext()
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def api_client(self) -> ApiClient:
|
|
56
|
+
return ApiClient(self._config, self._execution_context)
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def assets(self) -> AssetsService:
|
|
60
|
+
return AssetsService(self._config, self._execution_context)
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
def processes(self) -> ProcessesService:
|
|
64
|
+
return ProcessesService(self._config, self._execution_context)
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def actions(self) -> ActionsService:
|
|
68
|
+
return ActionsService(self._config, self._execution_context)
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def buckets(self) -> BucketsService:
|
|
72
|
+
return BucketsService(self._config, self._execution_context)
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def connections(self) -> ConnectionsService:
|
|
76
|
+
return ConnectionsService(self._config, self._execution_context)
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def context_grounding(self) -> ContextGroundingService:
|
|
80
|
+
if not self._folders_service:
|
|
81
|
+
self._folders_service = FolderService(self._config, self._execution_context)
|
|
82
|
+
return ContextGroundingService(
|
|
83
|
+
self._config, self._execution_context, self._folders_service
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
@property
|
|
87
|
+
def queues(self) -> QueuesService:
|
|
88
|
+
return QueuesService(self._config, self._execution_context)
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def jobs(self) -> JobsService:
|
|
92
|
+
return JobsService(self._config, self._execution_context)
|
|
93
|
+
|
|
94
|
+
@property
|
|
95
|
+
def folders(self) -> FolderService:
|
|
96
|
+
if not self._folders_service:
|
|
97
|
+
self._folders_service = FolderService(self._config, self._execution_context)
|
|
98
|
+
return self._folders_service
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from ._endpoint import Endpoint
|
|
2
|
+
from ._infer_bindings import get_inferred_bindings_names, infer_bindings
|
|
3
|
+
from ._logs import setup_logging
|
|
4
|
+
from ._request_override import header_folder
|
|
5
|
+
from ._request_spec import RequestSpec
|
|
6
|
+
from ._user_agent import header_user_agent, user_agent_value
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"Endpoint",
|
|
10
|
+
"setup_logging",
|
|
11
|
+
"RequestSpec",
|
|
12
|
+
"header_folder",
|
|
13
|
+
"get_inferred_bindings_names",
|
|
14
|
+
"infer_bindings",
|
|
15
|
+
"header_user_agent",
|
|
16
|
+
"user_agent_value",
|
|
17
|
+
]
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Endpoint(str):
|
|
5
|
+
"""A string subclass representing a normalized API endpoint path.
|
|
6
|
+
|
|
7
|
+
This class ensures consistent endpoint formatting by:
|
|
8
|
+
- Adding a leading slash if missing
|
|
9
|
+
- Removing trailing slashes (except for root '/')
|
|
10
|
+
- Stripping query parameters
|
|
11
|
+
|
|
12
|
+
The class supports string formatting for dynamic path parameters.
|
|
13
|
+
|
|
14
|
+
Examples:
|
|
15
|
+
>>> endpoint = Endpoint("/api/v1/users/{id}")
|
|
16
|
+
>>> endpoint.format(id=123)
|
|
17
|
+
'/api/v1/users/123'
|
|
18
|
+
|
|
19
|
+
>>> endpoint = Endpoint("projects")
|
|
20
|
+
>>> str(endpoint)
|
|
21
|
+
'/projects'
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
endpoint (str): The endpoint path to normalize. May include format placeholders
|
|
25
|
+
for dynamic values (e.g. "/users/{id}").
|
|
26
|
+
|
|
27
|
+
Raises:
|
|
28
|
+
ValueError: If format() is called with None or empty string arguments.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __new__(cls, endpoint: str) -> "Endpoint":
|
|
32
|
+
if not endpoint.startswith("/"):
|
|
33
|
+
endpoint = f"/{endpoint}"
|
|
34
|
+
|
|
35
|
+
if endpoint != "/" and endpoint.endswith("/"):
|
|
36
|
+
endpoint = endpoint[:-1]
|
|
37
|
+
|
|
38
|
+
endpoint = endpoint.split("?")[0]
|
|
39
|
+
|
|
40
|
+
return super().__new__(cls, endpoint)
|
|
41
|
+
|
|
42
|
+
def format(self, *args: Any, **kwargs: Any) -> str:
|
|
43
|
+
"""Formats the endpoint with the given arguments."""
|
|
44
|
+
for index, arg in enumerate(args):
|
|
45
|
+
if not self._is_valid_value(arg):
|
|
46
|
+
raise ValueError(f"Positional argument `{index}` is `{arg}`.")
|
|
47
|
+
|
|
48
|
+
for key, value in kwargs.items():
|
|
49
|
+
if not self._is_valid_value(value):
|
|
50
|
+
raise ValueError(f"Keyword argument `{key}` is `{value}`.")
|
|
51
|
+
|
|
52
|
+
return super().format(*args, **kwargs)
|
|
53
|
+
|
|
54
|
+
def __repr__(self) -> str:
|
|
55
|
+
return f"Endpoint({super().__str__()!r})"
|
|
56
|
+
|
|
57
|
+
def _is_valid_value(self, value: Any) -> bool:
|
|
58
|
+
return value is not None and value != ""
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def service(self) -> str:
|
|
62
|
+
"""Extracts and returns the service name from the endpoint path.
|
|
63
|
+
|
|
64
|
+
The service name is expected to be the first path segment after the leading slash,
|
|
65
|
+
with any underscores removed.
|
|
66
|
+
|
|
67
|
+
Examples:
|
|
68
|
+
>>> endpoint = Endpoint("/cloud_/projects")
|
|
69
|
+
>>> endpoint.service
|
|
70
|
+
'cloud'
|
|
71
|
+
|
|
72
|
+
>>> endpoint = Endpoint("/automation_hub_/assets")
|
|
73
|
+
>>> endpoint.service
|
|
74
|
+
'automationhub'
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
str: The service name with underscores removed.
|
|
78
|
+
"""
|
|
79
|
+
return self.split("/")[1].replace("_", "")
|