1
1
from typing import Any , Dict , Literal , Optional , Union
2
2
from warnings import warn
3
3
4
- from httpx import HTTPError , Response
4
+ from httpx import AsyncClient , HTTPError , Response
5
5
6
6
from ..errors import FunctionsHttpError , FunctionsRelayError
7
7
from ..utils import (
8
- AsyncClient ,
9
8
FunctionRegion ,
10
9
is_http_url ,
11
10
is_valid_jwt ,
@@ -19,8 +18,9 @@ def __init__(
19
18
self ,
20
19
url : str ,
21
20
headers : Dict ,
22
- timeout : int ,
23
- verify : bool = True ,
21
+ httpx : Optional [AsyncClient ] = None ,
22
+ timeout : Optional [int ] = None ,
23
+ verify : Optional [bool ] = None ,
24
24
proxy : Optional [str ] = None ,
25
25
):
26
26
if not is_http_url (url ):
@@ -30,15 +30,33 @@ def __init__(
30
30
"User-Agent" : f"supabase-py/functions-py v{ __version__ } " ,
31
31
** headers ,
32
32
}
33
- self ._client = AsyncClient (
34
- base_url = self .url ,
35
- headers = self .headers ,
36
- verify = bool (verify ),
37
- timeout = int (abs (timeout )),
38
- proxy = proxy ,
39
- follow_redirects = True ,
40
- http2 = True ,
41
- )
33
+
34
+ if timeout is not None :
35
+ warn ("The 'timeout' parameter is deprecated. Please configure it in the httpx client instead." , DeprecationWarning , stacklevel = 2 )
36
+ if verify is not None :
37
+ warn ("The 'verify' parameter is deprecated. Please configure it in the httpx client instead." , DeprecationWarning , stacklevel = 2 )
38
+ if proxy is not None :
39
+ warn ("The 'proxy' parameter is deprecated. Please configure it in the httpx client instead." , DeprecationWarning , stacklevel = 2 )
40
+
41
+ self .verify = bool (verify ) if verify is not None else True
42
+ self .timeout = int (abs (timeout )) if timeout is not None else 60
43
+
44
+ if httpx is not None :
45
+ self ._client = httpx
46
+ self ._client .base_url = self .url
47
+ self ._client .headers = self .headers
48
+ self ._client .follow_redirects = True
49
+ self ._client .http2 = True
50
+ else :
51
+ self ._client = AsyncClient (
52
+ base_url = self .url ,
53
+ headers = self .headers ,
54
+ verify = self .verify ,
55
+ timeout = self .timeout ,
56
+ proxy = proxy ,
57
+ follow_redirects = True ,
58
+ http2 = True ,
59
+ )
42
60
43
61
async def _request (
44
62
self ,
0 commit comments