Skip to content

Implement getIndexes method #373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
28 changes: 28 additions & 0 deletions arango/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @alexbakharew,

Can you add these two parameters to the indexes() (at line 1220) method instead?
I think having two methods will get redundant, and indexes() is already a known part of the API and documented.

Please either include these parameters as Optional[bool] and set them to None by default, or just bool with a default value of False. You might have to adjust the format_index method in order to get the full result back.

"""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],
Expand Down
Loading