diff --git a/packages/uipath-platform/pyproject.toml b/packages/uipath-platform/pyproject.toml index 69289ca85..3b44e14cc 100644 --- a/packages/uipath-platform/pyproject.toml +++ b/packages/uipath-platform/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "uipath-platform" -version = "0.1.84" +version = "0.1.85" description = "HTTP client library for programmatic access to UiPath Platform" readme = { file = "README.md", content-type = "text/markdown" } requires-python = ">=3.11" diff --git a/packages/uipath-platform/src/uipath/platform/orchestrator/_assets_service.py b/packages/uipath-platform/src/uipath/platform/orchestrator/_assets_service.py index 2e673fb7c..78f78543b 100644 --- a/packages/uipath-platform/src/uipath/platform/orchestrator/_assets_service.py +++ b/packages/uipath-platform/src/uipath/platform/orchestrator/_assets_service.py @@ -602,6 +602,51 @@ async def update_async( return response.json() + @traced(name="assets_exists", run_type="uipath") + def exists( + self, + name: str, + *, + folder_key: Optional[str] = None, + folder_path: Optional[str] = None, + ) -> bool: + """Check whether an asset with the given name exists. + + Args: + name (str): The name of the asset. + folder_key (Optional[str]): The key of the folder. Override the default one set in the SDK config. + folder_path (Optional[str]): The path of the folder. Override the default one set in the SDK config. + + Returns: + bool: True if an asset with the given name exists, False otherwise. + + Examples: + ```python + from uipath.platform import UiPath + + client = UiPath() + + client.assets.exists(name="MyAsset") + ``` + """ + spec = self._list_spec( + folder_path=folder_path, + folder_key=folder_key, + filter=f"Name eq '{name}'", + orderby=None, + skip=0, + top=1, + ) + response = self.request( + spec.method, + url=spec.endpoint, + params=spec.params, + content=spec.content, + headers=spec.headers, + json=spec.json, + ) + return len(response.json().get("value", [])) > 0 + @property def custom_headers(self) -> Dict[str, str]: return self.folder_headers diff --git a/packages/uipath-platform/uv.lock b/packages/uipath-platform/uv.lock index da079bd3f..0f6f56edb 100644 --- a/packages/uipath-platform/uv.lock +++ b/packages/uipath-platform/uv.lock @@ -1095,7 +1095,7 @@ dev = [ [[package]] name = "uipath-platform" -version = "0.1.84" +version = "0.1.85" source = { editable = "." } dependencies = [ { name = "httpx" }, diff --git a/packages/uipath/uv.lock b/packages/uipath/uv.lock index ecd4aed07..0cbe7350a 100644 --- a/packages/uipath/uv.lock +++ b/packages/uipath/uv.lock @@ -2691,7 +2691,7 @@ dev = [ [[package]] name = "uipath-platform" -version = "0.1.84" +version = "0.1.85" source = { editable = "../uipath-platform" } dependencies = [ { name = "httpx" },