Skip to content

Commit f6351a3

Browse files
algolia-botmillotpFluf22
committed
feat(clients): add helper to check if an index exists (generated)
algolia/api-clients-automation#3646 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Pierre Millot <[email protected]> Co-authored-by: Thomas Raffray <[email protected]>
1 parent b347a12 commit f6351a3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

algoliasearch/search/client.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,19 @@ async def _copy() -> UpdatedAtResponse:
596596
move_operation_response=move_operation_response,
597597
)
598598

599+
async def index_exists(self, index_name: str) -> bool:
600+
"""
601+
Helper: Checks if the given `index_name` exists.
602+
"""
603+
try:
604+
await self.get_settings(index_name)
605+
except Exception as e:
606+
if isinstance(e, RequestException) and e.status_code == 404:
607+
return False
608+
raise e
609+
610+
return True
611+
599612
async def add_api_key_with_http_info(
600613
self,
601614
api_key: ApiKey,

0 commit comments

Comments
 (0)