Skip to content

Commit d2853a2

Browse files
authored
Merge pull request #394 from UiPath/feat/jobs-folder-support
feat: add folder support for job retrieve
2 parents 5ac714c + 8e92d4f commit d2853a2

File tree

3 files changed

+64
-6
lines changed

3 files changed

+64
-6
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.0.61"
3+
version = "2.0.62"
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.10"

src/uipath/_services/jobs_service.py

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ async def resume_async(
113113
114114
async def main(): # noqa: D103
115115
payload = await sdk.jobs.resume_async(job_id="38073051", payload="The response")
116-
print(payload)
117-
118116
119117
asyncio.run(main())
120118
```
@@ -154,23 +152,78 @@ def custom_headers(self) -> Dict[str, str]:
154152
def retrieve(
155153
self,
156154
job_key: str,
155+
*,
156+
folder_key: Optional[str] = None,
157+
folder_path: Optional[str] = None,
157158
) -> Job:
158-
spec = self._retrieve_spec(job_key=job_key)
159+
"""Retrieve a job identified by its key.
160+
161+
Args:
162+
job_key (str): The job unique identifier.
163+
folder_key (Optional[str]): The key of the folder in which the job was executed.
164+
folder_path (Optional[str]): The path of the folder in which the job was executed.
165+
166+
Returns:
167+
Job: The retrieved job.
168+
169+
Examples:
170+
```python
171+
from uipath import UiPath
172+
173+
sdk = UiPath()
174+
job = sdk.jobs.retrieve(job_key="ee9327fd-237d-419e-86ef-9946b34461e3", folder_path="Shared")
175+
```
176+
"""
177+
spec = self._retrieve_spec(
178+
job_key=job_key, folder_key=folder_key, folder_path=folder_path
179+
)
159180
response = self.request(
160181
spec.method,
161182
url=spec.endpoint,
183+
headers=spec.headers,
162184
)
163185

164186
return Job.model_validate(response.json())
165187

166188
async def retrieve_async(
167189
self,
168190
job_key: str,
191+
*,
192+
folder_key: Optional[str] = None,
193+
folder_path: Optional[str] = None,
169194
) -> Job:
170-
spec = self._retrieve_spec(job_key=job_key)
195+
"""Asynchronously retrieve a job identified by its key.
196+
197+
Args:
198+
job_key (str): The job unique identifier.
199+
folder_key (Optional[str]): The key of the folder in which the job was executed.
200+
folder_path (Optional[str]): The path of the folder in which the job was executed.
201+
202+
Returns:
203+
Job: The retrieved job.
204+
205+
Examples:
206+
```python
207+
import asyncio
208+
209+
from uipath import UiPath
210+
211+
sdk = UiPath()
212+
213+
214+
async def main(): # noqa: D103
215+
job = await sdk.jobs.retrieve_async(job_key="ee9327fd-237d-419e-86ef-9946b34461e3", folder_path="Shared")
216+
217+
asyncio.run(main())
218+
```
219+
"""
220+
spec = self._retrieve_spec(
221+
job_key=job_key, folder_key=folder_key, folder_path=folder_path
222+
)
171223
response = await self.request_async(
172224
spec.method,
173225
url=spec.endpoint,
226+
headers=spec.headers,
174227
)
175228

176229
return Job.model_validate(response.json())
@@ -268,12 +321,17 @@ def _retrieve_spec(
268321
self,
269322
*,
270323
job_key: str,
324+
folder_key: Optional[str] = None,
325+
folder_path: Optional[str] = None,
271326
) -> RequestSpec:
272327
return RequestSpec(
273328
method="GET",
274329
endpoint=Endpoint(
275330
f"/orchestrator_/odata/Jobs/UiPath.Server.Configuration.OData.GetByKey(identifier={job_key})"
276331
),
332+
headers={
333+
**header_folder(folder_key, folder_path),
334+
},
277335
)
278336

279337
@traced(name="jobs_list_attachments", run_type="uipath")

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)