@@ -24,7 +24,7 @@ class GraphClientFactory(KiotaClientFactory):
24
24
@staticmethod
25
25
def create_with_default_middleware (
26
26
api_version : APIVersion = APIVersion .v1 ,
27
- client : httpx .AsyncClient = KiotaClientFactory . get_default_client () ,
27
+ client : Optional [ httpx .AsyncClient ] = None ,
28
28
host : NationalClouds = NationalClouds .Global ,
29
29
options : Optional [Dict [str , RequestOption ]] = None
30
30
) -> httpx .AsyncClient :
@@ -44,6 +44,8 @@ def create_with_default_middleware(
44
44
Returns:
45
45
httpx.AsyncClient: An instance of the AsyncClient object
46
46
"""
47
+ if client is None :
48
+ client = KiotaClientFactory .get_default_client ()
47
49
client .base_url = GraphClientFactory ._get_base_url (host , api_version ) # type: ignore
48
50
middleware = KiotaClientFactory .get_default_middleware (options )
49
51
telemetry_handler = GraphClientFactory ._get_telemetry_handler (options )
@@ -54,7 +56,7 @@ def create_with_default_middleware(
54
56
def create_with_custom_middleware (
55
57
middleware : Optional [List [BaseMiddleware ]],
56
58
api_version : APIVersion = APIVersion .v1 ,
57
- client : httpx .AsyncClient = KiotaClientFactory . get_default_client () ,
59
+ client : Optional [ httpx .AsyncClient ] = None ,
58
60
host : NationalClouds = NationalClouds .Global ,
59
61
) -> httpx .AsyncClient :
60
62
"""Applies a custom middleware chain to the HTTP Client
@@ -70,6 +72,8 @@ def create_with_custom_middleware(
70
72
host (NationalClouds): The national clound endpoint to be used.
71
73
Defaults to NationalClouds.Global.
72
74
"""
75
+ if client is None :
76
+ client = KiotaClientFactory .get_default_client ()
73
77
client .base_url = GraphClientFactory ._get_base_url (host , api_version ) # type: ignore
74
78
return GraphClientFactory ._load_middleware_to_client (client , middleware )
75
79
0 commit comments