11
11
12
12
13
13
class HTTPClientFactory :
14
- """
15
- Constructs HTTP Client(session) instances configured with either custom or default
14
+ """Constructs native HTTP Client(session) instances configured with either custom or default
16
15
pipeline of middleware.
16
+
17
+ :func: Class constructor accepts a user provided session object and kwargs to configure the
18
+ request handling behaviour of the client
19
+ :keyword enum api_version: The Microsoft Graph API version to be used, for example
20
+ `APIVersion.v1` (default). This value is used in setting the base url for all requests for
21
+ that session.
22
+ :class:`~msgraphcore.enums.APIVersion` defines valid API versions.
23
+ :keyword enum cloud: a supported Microsoft Graph cloud endpoint.
24
+ Defaults to `NationalClouds.Global`
25
+ :class:`~msgraphcore.enums.NationalClouds` defines supported sovereign clouds.
26
+ :keyword tuple timeout: Default connection and read timeout values for all session requests.
27
+ Specify a tuple in the form of Tuple(connect_timeout, read_timeout) if you would like to set
28
+ the values separately. If you specify a single value for the timeout, the timeout value will
29
+ be applied to both the connect and the read timeouts.
30
+ :keyword obj session: A custom Session instance from the python requests library
17
31
"""
18
32
def __init__ (self , ** kwargs ):
19
33
"""Class constructor that accepts a user provided session object and kwargs
@@ -27,15 +41,24 @@ def __init__(self, **kwargs):
27
41
self ._set_default_timeout ()
28
42
29
43
def create_with_default_middleware (self , credential : TokenCredential , ** kwargs ) -> Session :
30
- """Applies the default middleware chain to the HTTP Client"""
44
+ """Applies the default middleware chain to the HTTP Client
45
+
46
+ :param credential: TokenCredential used to acquire an access token for the Microsoft
47
+ Graph API. Created through one of the credential classes from `azure.identity`
48
+ """
31
49
middleware = [
32
50
AuthorizationHandler (credential , ** kwargs ),
33
51
]
34
52
self ._register (middleware )
35
53
return self .session
36
54
37
55
def create_with_custom_middleware (self , middleware : [BaseMiddleware ]) -> Session :
38
- """Applies a custom middleware chain to the HTTP Client """
56
+ """Applies a custom middleware chain to the HTTP Client
57
+
58
+ :param list middleware: Custom middleware(HTTPAdapter) list that will be used to create
59
+ a middleware pipeline. The middleware should be arranged in the order in which they will
60
+ modify the request.
61
+ """
39
62
if not middleware :
40
63
raise ValueError ("Please provide a list of custom middleware" )
41
64
self ._register (middleware )
0 commit comments