14
14
from ._enums import APIVersion , NationalClouds
15
15
from .middleware import GraphTelemetryHandler
16
16
17
- DEFAULT_CONNECTION_TIMEOUT : int = 30
18
- DEFAULT_REQUEST_TIMEOUT : int = 100
19
-
20
17
21
18
class GraphClientFactory (KiotaClientFactory ):
22
19
"""Constructs httpx.AsyncClient instances configured with either custom or default
@@ -33,16 +30,13 @@ def create_with_default_middleware(
33
30
Returns:
34
31
httpx.AsycClient: An instance of the AsyncClient object
35
32
"""
36
- timeout = httpx .Timeout (DEFAULT_REQUEST_TIMEOUT , connect = DEFAULT_CONNECTION_TIMEOUT )
37
- client = httpx .AsyncClient (
38
- base_url = GraphClientFactory ._get_base_url (host , api_version ),
39
- timeout = timeout ,
40
- http2 = True
41
- )
33
+ client = KiotaClientFactory .get_default_client ()
34
+ client .base_url = GraphClientFactory ._get_base_url (host , api_version )
42
35
current_transport = client ._transport
43
- middleware = KiotaClientFactory ._get_default_middleware ()
36
+
37
+ middleware = KiotaClientFactory .get_default_middleware ()
44
38
middleware .append (GraphTelemetryHandler ())
45
- middleware_pipeline = KiotaClientFactory ._create_middleware_pipeline (
39
+ middleware_pipeline = KiotaClientFactory .create_middleware_pipeline (
46
40
middleware , current_transport
47
41
)
48
42
@@ -64,14 +58,11 @@ def create_with_custom_middleware(
64
58
a middleware pipeline. The middleware should be arranged in the order in which they will
65
59
modify the request.
66
60
"""
67
- timeout = httpx .Timeout (DEFAULT_REQUEST_TIMEOUT , connect = DEFAULT_CONNECTION_TIMEOUT )
68
- client = httpx .AsyncClient (
69
- base_url = GraphClientFactory ._get_base_url (host , api_version ),
70
- timeout = timeout ,
71
- http2 = True
72
- )
61
+ client = KiotaClientFactory .get_default_client ()
62
+ client .base_url = GraphClientFactory ._get_base_url (host , api_version )
73
63
current_transport = client ._transport
74
- middleware_pipeline = KiotaClientFactory ._create_middleware_pipeline (
64
+
65
+ middleware_pipeline = KiotaClientFactory .create_middleware_pipeline (
75
66
middleware , current_transport
76
67
)
77
68
0 commit comments