Skip to content

Commit f7e687b

Browse files
committed
Add descriptive docstrings to GraphClient and HTTPCLientFactory for intellisense
1 parent ff9e39b commit f7e687b

File tree

2 files changed

+47
-5
lines changed

2 files changed

+47
-5
lines changed

msgraphcore/client_factory.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,23 @@
1111

1212

1313
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
1615
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
1731
"""
1832
def __init__(self, **kwargs):
1933
"""Class constructor that accepts a user provided session object and kwargs
@@ -27,15 +41,24 @@ def __init__(self, **kwargs):
2741
self._set_default_timeout()
2842

2943
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: Accesstoken used to access the Graph API. Created through one of the
47+
credential classes from `azure.identity`
48+
"""
3149
middleware = [
3250
AuthorizationHandler(credential, **kwargs),
3351
]
3452
self._register(middleware)
3553
return self.session
3654

3755
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+
"""
3962
if not middleware:
4063
raise ValueError("Please provide a list of custom middleware")
4164
self._register(middleware)

msgraphcore/graph_client.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,26 @@
99

1010

1111
class GraphClient:
12-
"""Constructs a custom HTTPClient to be used for requests against Microsoft Graph"""
12+
"""Constructs a custom HTTPClient to be used for requests against Microsoft Graph
13+
14+
:keyword credential: Accesstoken used to access the Graph API. Created through one of the
15+
credential classes from `azure.identity`
16+
:keyword list middleware: Custom middleware(HTTPAdapter) list that will be used to create
17+
a middleware pipeline. The middleware should be arranged in the order in which they will
18+
modify the request.
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
31+
"""
1332
__instance = None
1433

1534
def __new__(cls, *args, **kwargs):

0 commit comments

Comments
 (0)