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.15"
version = "0.1.16"
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 @@ -1690,6 +1690,184 @@ async def delete_index_async(
headers=spec.headers,
)

@resource_override(resource_type="index")
@traced(name="contextgrounding_list", run_type="uipath")
def list_indexes(
self,
folder_key: Optional[str] = None,
folder_path: Optional[str] = None,
) -> List[ContextGroundingIndex]:
"""List all context grounding indexes in a folder.

If no folder_key or folder_path is provided and no folder context is
configured, falls back to listing across all folders.

Args:
folder_key (Optional[str]): The key of the folder to list indexes from.
folder_path (Optional[str]): The path of the folder to list indexes from.

Returns:
List[ContextGroundingIndex]: A list of all indexes in the folder.
"""
resolved_folder_key = self._resolve_folder_key(folder_key, folder_path)
if not resolved_folder_key:
return self.retrieve_across_folders()

spec = self._list_spec(folder_key=resolved_folder_key)

response = self.request(
spec.method,
spec.endpoint,
params=spec.params,
headers=spec.headers,
).json()

return [
ContextGroundingIndex.model_validate(item)
for item in response.get("value", [])
]

@resource_override(resource_type="index")
@traced(name="contextgrounding_list", run_type="uipath")
async def list_indexes_async(
self,
folder_key: Optional[str] = None,
folder_path: Optional[str] = None,
) -> List[ContextGroundingIndex]:
"""Asynchronously list all context grounding indexes in a folder.

If no folder_key or folder_path is provided and no folder context is
configured, falls back to listing across all folders.

Args:
folder_key (Optional[str]): The key of the folder to list indexes from.
folder_path (Optional[str]): The path of the folder to list indexes from.

Returns:
List[ContextGroundingIndex]: A list of all indexes in the folder.
"""
resolved_folder_key = self._resolve_folder_key(folder_key, folder_path)
if not resolved_folder_key:
return await self.retrieve_across_folders_async()

spec = self._list_spec(folder_key=resolved_folder_key)

response = (
await self.request_async(
spec.method,
spec.endpoint,
params=spec.params,
headers=spec.headers,
)
).json()

return [
ContextGroundingIndex.model_validate(item)
for item in response.get("value", [])
]

@resource_override(resource_type="index")
@traced(name="contextgrounding_delete_by_name", run_type="uipath")
def delete_by_name(
self,
name: str,
folder_key: Optional[str] = None,
folder_path: Optional[str] = None,
) -> None:
"""Delete a context grounding index by its name.

This method retrieves the index by name and then deletes it.

Args:
name (str): The name of the context index to delete.
folder_key (Optional[str]): The key of the folder where the index resides.
folder_path (Optional[str]): The path of the folder where the index resides.

Raises:
Exception: If no index with the given name is found.
"""
index = self.retrieve(name, folder_key=folder_key, folder_path=folder_path)
self.delete_index(index, folder_key=folder_key, folder_path=folder_path)

@resource_override(resource_type="index")
@traced(name="contextgrounding_delete_by_name", run_type="uipath")
async def delete_by_name_async(
self,
name: str,
folder_key: Optional[str] = None,
folder_path: Optional[str] = None,
) -> None:
"""Asynchronously delete a context grounding index by its name.

This method retrieves the index by name and then deletes it.

Args:
name (str): The name of the context index to delete.
folder_key (Optional[str]): The key of the folder where the index resides.
folder_path (Optional[str]): The path of the folder where the index resides.

Raises:
Exception: If no index with the given name is found.
"""
index = await self.retrieve_async(
name, folder_key=folder_key, folder_path=folder_path
)
await self.delete_index_async(
index, folder_key=folder_key, folder_path=folder_path
)

@resource_override(resource_type="index")
@traced(name="contextgrounding_ingest_by_name", run_type="uipath")
def ingest_by_name(
Comment thread
pateljay43 marked this conversation as resolved.
self,
name: str,
folder_key: Optional[str] = None,
folder_path: Optional[str] = None,
) -> None:
"""Trigger ingestion on a context grounding index by its name.

This method retrieves the index by name and then triggers data ingestion.

Args:
name (str): The name of the context index to ingest.
folder_key (Optional[str]): The key of the folder where the index resides.
folder_path (Optional[str]): The path of the folder where the index resides.

Raises:
Exception: If no index with the given name is found.
IngestionInProgressException: If ingestion is already in progress.
"""
index = self.retrieve(name, folder_key=folder_key, folder_path=folder_path)
self.ingest_data(index, folder_key=folder_key, folder_path=folder_path)

@resource_override(resource_type="index")
@traced(name="contextgrounding_ingest_by_name", run_type="uipath")
async def ingest_by_name_async(
self,
name: str,
folder_key: Optional[str] = None,
folder_path: Optional[str] = None,
) -> None:
"""Asynchronously trigger ingestion on a context grounding index by its name.

This method retrieves the index by name and then triggers data ingestion.

Args:
name (str): The name of the context index to ingest.
folder_key (Optional[str]): The key of the folder where the index resides.
folder_path (Optional[str]): The path of the folder where the index resides.

Raises:
Exception: If no index with the given name is found.
IngestionInProgressException: If ingestion is already in progress.
"""
index = await self.retrieve_async(
name, folder_key=folder_key, folder_path=folder_path
)
await self.ingest_data_async(
index, folder_key=folder_key, folder_path=folder_path
)

def _ingest_spec(
self,
key: str,
Expand Down Expand Up @@ -1722,6 +1900,21 @@ def _retrieve_across_folders_spec(
params=params,
)

def _list_spec(
self,
folder_key: Optional[str] = None,
) -> RequestSpec:
return RequestSpec(
method="GET",
endpoint=Endpoint("/ecs_/v2/indexes"),
params={
"$expand": "dataSource",
},
headers={
**header_folder(folder_key, None),
},
)

def _retrieve_spec(
self,
name: str,
Expand Down
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/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath"
version = "2.10.38"
version = "2.10.39"
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
Expand Down
Loading
Loading