Skip to content

Commit f7eebdf

Browse files
committed
Listing analyzers
1 parent 1d3b3f5 commit f7eebdf

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

arangoasync/database.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from arangoasync.connection import Connection
1515
from arangoasync.errno import HTTP_FORBIDDEN, HTTP_NOT_FOUND
1616
from arangoasync.exceptions import (
17+
AnalyzerListError,
1718
AsyncJobClearError,
1819
AsyncJobListError,
1920
CollectionCreateError,
@@ -1461,6 +1462,28 @@ def response_handler(resp: Response) -> bool:
14611462

14621463
return await self._executor.execute(request, response_handler)
14631464

1465+
async def analyzers(self) -> Result[Jsons]:
1466+
"""List all analyzers in the database.
1467+
1468+
Returns:
1469+
list: List of analyzers with their properties.
1470+
1471+
Raises:
1472+
AnalyzerListError: If the operation fails.
1473+
1474+
References:
1475+
- `list-all-analyzers <https://docs.arangodb.com/stable/develop/http-api/analyzers/#list-all-analyzers>`__
1476+
""" # noqa: E501
1477+
request = Request(method=Method.GET, endpoint="/_api/analyzer")
1478+
1479+
def response_handler(resp: Response) -> Jsons:
1480+
if resp.is_success:
1481+
result: Jsons = self.deserializer.loads(resp.raw_body)["result"]
1482+
return result
1483+
raise AnalyzerListError(resp, request)
1484+
1485+
return await self._executor.execute(request, response_handler)
1486+
14641487
async def has_user(self, username: str) -> Result[bool]:
14651488
"""Check if a user exists.
14661489

arangoasync/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ class AQLQueryValidateError(ArangoServerError):
135135
"""Failed to parse and validate query."""
136136

137137

138+
class AnalyzerListError(ArangoServerError):
139+
"""Failed to retrieve analyzers."""
140+
141+
138142
class AsyncExecuteError(ArangoServerError):
139143
"""Failed to execute async API request."""
140144

0 commit comments

Comments
 (0)