File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -2861,6 +2861,21 @@ def response_handler(resp: Response) -> Any:
28612861
28622862 return await self ._executor .execute (request , response_handler )
28632863
2864+ async def request (self , request : Request ) -> Result [Response ]:
2865+ """Execute a custom request.
2866+
2867+ Args:
2868+ request (Request): Request object to be executed.
2869+
2870+ Returns:
2871+ Response: Response object containing the result of the request.
2872+ """
2873+
2874+ def response_handler (resp : Response ) -> Response :
2875+ return resp
2876+
2877+ return await self ._executor .execute (request , response_handler )
2878+
28642879
28652880class StandardDatabase (Database ):
28662881 """Standard database API wrapper.
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ information.
1414
1515 from arangoasync import ArangoClient
1616 from arangoasync.auth import Auth
17+ from arangoasync.request import Method, Request
1718
1819 # Initialize the client for ArangoDB.
1920 async with ArangoClient(hosts = " http://localhost:8529" ) as client:
@@ -60,4 +61,10 @@ information.
6061 # Delete the database. Note that the new users will remain.
6162 await sys_db.delete_database(" test" )
6263
64+ # Example of a custom request
65+ request = Request(
66+ method = Method.POST , endpoint = " /_admin/execute" , data = " return 1" .encode(" utf-8" )
67+ )
68+ response = await sys_db.request(request)
69+
6370 See :class: `arangoasync.client.ArangoClient ` and :class: `arangoasync.database.StandardDatabase ` for API specification.
Original file line number Diff line number Diff line change 11import asyncio
22import datetime
3+ import json
34
45import pytest
56from packaging import version
3637 ServerTimeError ,
3738 ServerVersionError ,
3839)
40+ from arangoasync .request import Method , Request
3941from arangoasync .typings import CollectionType , KeyOptions , UserInfo
4042from tests .helpers import generate_col_name , generate_db_name , generate_username
4143
@@ -157,6 +159,13 @@ async def test_database_misc_methods(
157159 )
158160 await db .compact ()
159161
162+ # Custom Request
163+ request = Request (
164+ method = Method .POST , endpoint = "/_admin/execute" , data = "return 1" .encode ("utf-8" )
165+ )
166+ response = await sys_db .request (request )
167+ assert json .loads (response .raw_body ) == 1
168+
160169
161170@pytest .mark .asyncio
162171async def test_create_drop_database (
You can’t perform that action at this time.
0 commit comments