@@ -812,11 +812,13 @@ async def health(self) -> Health:
812812
813813 return Health (** response .json ())
814814
815- async def swap_indexes (self , indexes : list [tuple [str , str ]]) -> TaskInfo :
815+ async def swap_indexes (self , indexes : list [tuple [str , str ]], rename : bool = False ) -> TaskInfo :
816816 """Swap two indexes.
817817
818818 Args:
819819 indexes: A list of tuples, each tuple should contain the indexes to swap.
820+ rename: Use rename false if you are swapping two existing indexes. Use rename true if
821+ the second index in your array does not exist. Default = False
820822
821823 Returns:
822824 The details of the task.
@@ -830,7 +832,10 @@ async def swap_indexes(self, indexes: list[tuple[str, str]]) -> TaskInfo:
830832 >>> async with AsyncClient("http://localhost.com", "masterKey") as client:
831833 >>> index = await client.swap_indexes([("index_a", "index_b")])
832834 """
833- processed_indexes = [{"indexes" : x } for x in indexes ]
835+ if rename :
836+ processed_indexes = [{"indexes" : x , "rename" : True } for x in indexes ]
837+ else :
838+ processed_indexes = [{"indexes" : x } for x in indexes ]
834839 response = await self ._http_requests .post ("swap-indexes" , processed_indexes )
835840
836841 return TaskInfo (** response .json ())
@@ -1775,11 +1780,13 @@ def health(self) -> Health:
17751780
17761781 return Health (** response .json ())
17771782
1778- def swap_indexes (self , indexes : list [tuple [str , str ]]) -> TaskInfo :
1783+ def swap_indexes (self , indexes : list [tuple [str , str ]], rename : bool = False ) -> TaskInfo :
17791784 """Swap two indexes.
17801785
17811786 Args:
17821787 indexes: A list of tuples, each tuple should contain the indexes to swap.
1788+ rename: Use rename false if you are swapping two existing indexes. Use rename true if
1789+ the second index in your array does not exist. Default = False
17831790
17841791 Returns:
17851792 The details of the task.
@@ -1793,7 +1800,10 @@ def swap_indexes(self, indexes: list[tuple[str, str]]) -> TaskInfo:
17931800 >>> client = Client("http://localhost.com", "masterKey")
17941801 >>> index = client.swap_indexes([("index_a", "index_b")])
17951802 """
1796- processed_indexes = [{"indexes" : x } for x in indexes ]
1803+ if rename :
1804+ processed_indexes = [{"indexes" : x , "rename" : True } for x in indexes ]
1805+ else :
1806+ processed_indexes = [{"indexes" : x } for x in indexes ]
17971807 response = self ._http_requests .post ("swap-indexes" , processed_indexes )
17981808
17991809 return TaskInfo (** response .json ())
0 commit comments