From 815a03b95d553ab23a8dee12fb7b09c4457e9ece Mon Sep 17 00:00:00 2001 From: Alexey Bakharew Date: Mon, 9 Sep 2024 19:34:11 +0200 Subject: [PATCH] Initial commit --- arango/collection.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/arango/collection.py b/arango/collection.py index 446200fb..64df8d4a 100644 --- a/arango/collection.py +++ b/arango/collection.py @@ -1299,6 +1299,34 @@ def response_handler(resp: Response) -> Json: return self._execute(request, response_handler) + def get_indexes(self, with_stats: bool, with_hidden: bool) -> Result[Json]: + """Return collection indexes. + :param with_stats: Include index statistics. + :type with_stats:bool + :param with_hidden: Include hidden indexes. + :type with_hidden:bool + :return: Index details + :rtype: dict + :raise serene.exceptions.IndexGetError: If retrieval fails. + """ + request = Request( + method="get", + endpoint=f"/_api/index", + params={ + "collection": self.name, + "withStats": with_stats, + "withHidden": with_hidden + } + ) + + def response_handler(resp: Response) -> Json: + if not resp.is_success: + raise IndexGetError(resp, request) + + return resp.body + + return self._execute(request, response_handler) + def add_hash_index( self, fields: Sequence[str],