@@ -1690,6 +1690,184 @@ async def delete_index_async(
16901690 headers = spec .headers ,
16911691 )
16921692
1693+ @resource_override (resource_type = "index" )
1694+ @traced (name = "contextgrounding_list" , run_type = "uipath" )
1695+ def list_indexes (
1696+ self ,
1697+ folder_key : Optional [str ] = None ,
1698+ folder_path : Optional [str ] = None ,
1699+ ) -> List [ContextGroundingIndex ]:
1700+ """List all context grounding indexes in a folder.
1701+
1702+ If no folder_key or folder_path is provided and no folder context is
1703+ configured, falls back to listing across all folders.
1704+
1705+ Args:
1706+ folder_key (Optional[str]): The key of the folder to list indexes from.
1707+ folder_path (Optional[str]): The path of the folder to list indexes from.
1708+
1709+ Returns:
1710+ List[ContextGroundingIndex]: A list of all indexes in the folder.
1711+ """
1712+ resolved_folder_key = self ._resolve_folder_key (folder_key , folder_path )
1713+ if not resolved_folder_key :
1714+ return self .retrieve_across_folders ()
1715+
1716+ spec = self ._list_spec (folder_key = resolved_folder_key )
1717+
1718+ response = self .request (
1719+ spec .method ,
1720+ spec .endpoint ,
1721+ params = spec .params ,
1722+ headers = spec .headers ,
1723+ ).json ()
1724+
1725+ return [
1726+ ContextGroundingIndex .model_validate (item )
1727+ for item in response .get ("value" , [])
1728+ ]
1729+
1730+ @resource_override (resource_type = "index" )
1731+ @traced (name = "contextgrounding_list" , run_type = "uipath" )
1732+ async def list_indexes_async (
1733+ self ,
1734+ folder_key : Optional [str ] = None ,
1735+ folder_path : Optional [str ] = None ,
1736+ ) -> List [ContextGroundingIndex ]:
1737+ """Asynchronously list all context grounding indexes in a folder.
1738+
1739+ If no folder_key or folder_path is provided and no folder context is
1740+ configured, falls back to listing across all folders.
1741+
1742+ Args:
1743+ folder_key (Optional[str]): The key of the folder to list indexes from.
1744+ folder_path (Optional[str]): The path of the folder to list indexes from.
1745+
1746+ Returns:
1747+ List[ContextGroundingIndex]: A list of all indexes in the folder.
1748+ """
1749+ resolved_folder_key = self ._resolve_folder_key (folder_key , folder_path )
1750+ if not resolved_folder_key :
1751+ return await self .retrieve_across_folders_async ()
1752+
1753+ spec = self ._list_spec (folder_key = resolved_folder_key )
1754+
1755+ response = (
1756+ await self .request_async (
1757+ spec .method ,
1758+ spec .endpoint ,
1759+ params = spec .params ,
1760+ headers = spec .headers ,
1761+ )
1762+ ).json ()
1763+
1764+ return [
1765+ ContextGroundingIndex .model_validate (item )
1766+ for item in response .get ("value" , [])
1767+ ]
1768+
1769+ @resource_override (resource_type = "index" )
1770+ @traced (name = "contextgrounding_delete_by_name" , run_type = "uipath" )
1771+ def delete_by_name (
1772+ self ,
1773+ name : str ,
1774+ folder_key : Optional [str ] = None ,
1775+ folder_path : Optional [str ] = None ,
1776+ ) -> None :
1777+ """Delete a context grounding index by its name.
1778+
1779+ This method retrieves the index by name and then deletes it.
1780+
1781+ Args:
1782+ name (str): The name of the context index to delete.
1783+ folder_key (Optional[str]): The key of the folder where the index resides.
1784+ folder_path (Optional[str]): The path of the folder where the index resides.
1785+
1786+ Raises:
1787+ Exception: If no index with the given name is found.
1788+ """
1789+ index = self .retrieve (name , folder_key = folder_key , folder_path = folder_path )
1790+ self .delete_index (index , folder_key = folder_key , folder_path = folder_path )
1791+
1792+ @resource_override (resource_type = "index" )
1793+ @traced (name = "contextgrounding_delete_by_name" , run_type = "uipath" )
1794+ async def delete_by_name_async (
1795+ self ,
1796+ name : str ,
1797+ folder_key : Optional [str ] = None ,
1798+ folder_path : Optional [str ] = None ,
1799+ ) -> None :
1800+ """Asynchronously delete a context grounding index by its name.
1801+
1802+ This method retrieves the index by name and then deletes it.
1803+
1804+ Args:
1805+ name (str): The name of the context index to delete.
1806+ folder_key (Optional[str]): The key of the folder where the index resides.
1807+ folder_path (Optional[str]): The path of the folder where the index resides.
1808+
1809+ Raises:
1810+ Exception: If no index with the given name is found.
1811+ """
1812+ index = await self .retrieve_async (
1813+ name , folder_key = folder_key , folder_path = folder_path
1814+ )
1815+ await self .delete_index_async (
1816+ index , folder_key = folder_key , folder_path = folder_path
1817+ )
1818+
1819+ @resource_override (resource_type = "index" )
1820+ @traced (name = "contextgrounding_ingest_by_name" , run_type = "uipath" )
1821+ def ingest_by_name (
1822+ self ,
1823+ name : str ,
1824+ folder_key : Optional [str ] = None ,
1825+ folder_path : Optional [str ] = None ,
1826+ ) -> None :
1827+ """Trigger ingestion on a context grounding index by its name.
1828+
1829+ This method retrieves the index by name and then triggers data ingestion.
1830+
1831+ Args:
1832+ name (str): The name of the context index to ingest.
1833+ folder_key (Optional[str]): The key of the folder where the index resides.
1834+ folder_path (Optional[str]): The path of the folder where the index resides.
1835+
1836+ Raises:
1837+ Exception: If no index with the given name is found.
1838+ IngestionInProgressException: If ingestion is already in progress.
1839+ """
1840+ index = self .retrieve (name , folder_key = folder_key , folder_path = folder_path )
1841+ self .ingest_data (index , folder_key = folder_key , folder_path = folder_path )
1842+
1843+ @resource_override (resource_type = "index" )
1844+ @traced (name = "contextgrounding_ingest_by_name" , run_type = "uipath" )
1845+ async def ingest_by_name_async (
1846+ self ,
1847+ name : str ,
1848+ folder_key : Optional [str ] = None ,
1849+ folder_path : Optional [str ] = None ,
1850+ ) -> None :
1851+ """Asynchronously trigger ingestion on a context grounding index by its name.
1852+
1853+ This method retrieves the index by name and then triggers data ingestion.
1854+
1855+ Args:
1856+ name (str): The name of the context index to ingest.
1857+ folder_key (Optional[str]): The key of the folder where the index resides.
1858+ folder_path (Optional[str]): The path of the folder where the index resides.
1859+
1860+ Raises:
1861+ Exception: If no index with the given name is found.
1862+ IngestionInProgressException: If ingestion is already in progress.
1863+ """
1864+ index = await self .retrieve_async (
1865+ name , folder_key = folder_key , folder_path = folder_path
1866+ )
1867+ await self .ingest_data_async (
1868+ index , folder_key = folder_key , folder_path = folder_path
1869+ )
1870+
16931871 def _ingest_spec (
16941872 self ,
16951873 key : str ,
@@ -1722,6 +1900,21 @@ def _retrieve_across_folders_spec(
17221900 params = params ,
17231901 )
17241902
1903+ def _list_spec (
1904+ self ,
1905+ folder_key : Optional [str ] = None ,
1906+ ) -> RequestSpec :
1907+ return RequestSpec (
1908+ method = "GET" ,
1909+ endpoint = Endpoint ("/ecs_/v2/indexes" ),
1910+ params = {
1911+ "$expand" : "dataSource" ,
1912+ },
1913+ headers = {
1914+ ** header_folder (folder_key , None ),
1915+ },
1916+ )
1917+
17251918 def _retrieve_spec (
17261919 self ,
17271920 name : str ,
0 commit comments