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:
2861
2861
2862
2862
return await self ._executor .execute (request , response_handler )
2863
2863
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
+
2864
2879
2865
2880
class StandardDatabase (Database ):
2866
2881
"""Standard database API wrapper.
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ information.
14
14
15
15
from arangoasync import ArangoClient
16
16
from arangoasync.auth import Auth
17
+ from arangoasync.request import Method, Request
17
18
18
19
# Initialize the client for ArangoDB.
19
20
async with ArangoClient(hosts = " http://localhost:8529" ) as client:
@@ -60,4 +61,10 @@ information.
60
61
# Delete the database. Note that the new users will remain.
61
62
await sys_db.delete_database(" test" )
62
63
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
+
63
70
See :class: `arangoasync.client.ArangoClient ` and :class: `arangoasync.database.StandardDatabase ` for API specification.
Original file line number Diff line number Diff line change 1
1
import asyncio
2
2
import datetime
3
+ import json
3
4
4
5
import pytest
5
6
from packaging import version
36
37
ServerTimeError ,
37
38
ServerVersionError ,
38
39
)
40
+ from arangoasync .request import Method , Request
39
41
from arangoasync .typings import CollectionType , KeyOptions , UserInfo
40
42
from tests .helpers import generate_col_name , generate_db_name , generate_username
41
43
@@ -157,6 +159,13 @@ async def test_database_misc_methods(
157
159
)
158
160
await db .compact ()
159
161
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
+
160
169
161
170
@pytest .mark .asyncio
162
171
async def test_create_drop_database (
You can’t perform that action at this time.
0 commit comments