Skip to content

Commit 1a479ce

Browse files
committed
feat: add AssetsService.exists() with mocked tests
1 parent 66dbaa8 commit 1a479ce

4 files changed

Lines changed: 48 additions & 3 deletions

File tree

packages/uipath-platform/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-platform"
3-
version = "0.1.84"
3+
version = "0.1.85"
44
description = "HTTP client library for programmatic access to UiPath Platform"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

packages/uipath-platform/src/uipath/platform/orchestrator/_assets_service.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,51 @@ async def update_async(
602602

603603
return response.json()
604604

605+
@traced(name="assets_exists", run_type="uipath")
606+
def exists(
607+
self,
608+
name: str,
609+
*,
610+
folder_key: Optional[str] = None,
611+
folder_path: Optional[str] = None,
612+
) -> bool:
613+
"""Check whether an asset with the given name exists.
614+
615+
Args:
616+
name (str): The name of the asset.
617+
folder_key (Optional[str]): The key of the folder. Override the default one set in the SDK config.
618+
folder_path (Optional[str]): The path of the folder. Override the default one set in the SDK config.
619+
620+
Returns:
621+
bool: True if an asset with the given name exists, False otherwise.
622+
623+
Examples:
624+
```python
625+
from uipath.platform import UiPath
626+
627+
client = UiPath()
628+
629+
client.assets.exists(name="MyAsset")
630+
```
631+
"""
632+
spec = self._list_spec(
633+
folder_path=folder_path,
634+
folder_key=folder_key,
635+
filter=f"Name eq '{name}'",
636+
orderby=None,
637+
skip=0,
638+
top=1,
639+
)
640+
response = self.request(
641+
spec.method,
642+
url=spec.endpoint,
643+
params=spec.params,
644+
content=spec.content,
645+
headers=spec.headers,
646+
json=spec.json,
647+
)
648+
return len(response.json().get("value", [])) > 0
649+
605650
@property
606651
def custom_headers(self) -> Dict[str, str]:
607652
return self.folder_headers

packages/uipath-platform/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.

packages/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)