diff --git a/arango/database.py b/arango/database.py index d4a5d8ed..627957f1 100644 --- a/arango/database.py +++ b/arango/database.py @@ -1128,6 +1128,20 @@ def response_handler(resp: Response) -> bool: return self._execute(request, response_handler) + def request(self, request: Request) -> Result[Response]: + """Execute a custom request. + + :param request: Request object to be executed. + :type request: Request + :return: Response object containing the result of the request. + :rtype: Response + """ + + def response_handler(resp: Response) -> Response: + return resp + + return self._executor.execute(request, response_handler) + def metrics(self) -> Result[str]: """Return server metrics in Prometheus format. diff --git a/tests/test_database.py b/tests/test_database.py index 8cd6df00..d572ec5b 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -43,6 +43,7 @@ from arango.foxx import Foxx from arango.pregel import Pregel from arango.replication import Replication +from arango.request import Request from arango.wal import WAL from tests.helpers import ( assert_raises, @@ -371,6 +372,14 @@ def test_database_misc_methods(client, sys_db, db, bad_db, cluster, secret, db_v availability = db.check_availability() assert isinstance(availability, str) + # Custom request + request = Request( + method="get", + endpoint="/_api/version", + ) + response = sys_db.request(request) + assert "version" in response.body + def test_database_management(db, sys_db, bad_db): # Test list databases