Skip to content

Commit 224fbc3

Browse files
authored
Merge pull request #964 from microsoftgraph/fix/graph-client-factory-initializion
Fix/graph client factory initializion
2 parents 7b5ad11 + 750f249 commit 224fbc3

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

src/msgraph_core/graph_client_factory.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@
1616
from .middleware.options import GraphTelemetryHandlerOption
1717

1818

19-
class GraphClientFactory(KiotaClientFactory):
19+
class GraphClientFactory():
2020
"""Constructs httpx.AsyncClient instances configured with either custom or default
2121
pipeline of graph specific middleware.
2222
"""
2323

2424
@staticmethod
25-
def create_with_default_middleware( # type: ignore
26-
# Breaking change to remove KiotaClientFactory as base class
25+
def create_with_default_middleware(
2726
api_version: APIVersion = APIVersion.v1,
2827
client: Optional[httpx.AsyncClient] = None,
2928
host: NationalClouds = NationalClouds.Global,
@@ -35,10 +34,13 @@ def create_with_default_middleware( # type: ignore
3534
Args:
3635
api_version (APIVersion): The Graph API version to be used.
3736
Defaults to APIVersion.v1.
38-
client (httpx.AsyncClient): The httpx.AsyncClient instance to be used.
39-
Defaults to KiotaClientFactory.get_default_client().
37+
This is only used if the client parameter is None.
38+
client (Optional[httpx.AsyncClient]]): The httpx.AsyncClient instance to be used.
39+
Defaults to None.
40+
When None, a client will be created with base url set to https://{host}/{api_version}.
4041
host (NationalClouds): The national clound endpoint to be used.
4142
Defaults to NationalClouds.Global.
43+
This is only used if the client parameter is None.
4244
options (Optional[dict[str, RequestOption]]): The request options to use when
4345
instantiating default middleware. Defaults to dict[str, RequestOption]=None.
4446
@@ -47,15 +49,15 @@ def create_with_default_middleware( # type: ignore
4749
"""
4850
if client is None:
4951
client = KiotaClientFactory.get_default_client()
50-
client.base_url = GraphClientFactory._get_base_url(host, api_version) # type: ignore
52+
client.base_url = GraphClientFactory._get_base_url(host, api_version)
53+
5154
middleware = KiotaClientFactory.get_default_middleware(options)
5255
telemetry_handler = GraphClientFactory._get_telemetry_handler(options)
5356
middleware.append(telemetry_handler)
5457
return GraphClientFactory._load_middleware_to_client(client, middleware)
5558

5659
@staticmethod
57-
def create_with_custom_middleware( # type: ignore
58-
# Breaking change to remove Kiota client factory as base class
60+
def create_with_custom_middleware(
5961
middleware: Optional[list[BaseMiddleware]],
6062
api_version: APIVersion = APIVersion.v1,
6163
client: Optional[httpx.AsyncClient] = None,
@@ -64,19 +66,24 @@ def create_with_custom_middleware( # type: ignore
6466
"""Applies a custom middleware chain to the HTTP Client
6567
6668
Args:
67-
middleware(list[BaseMiddleware]): Custom middleware list that will be used to create
68-
a middleware pipeline. The middleware should be arranged in the order in which they will
69-
modify the request.
70-
api_version (APIVersion): The Graph API version to be used.
69+
middleware(Optional[list[BaseMiddleware]]): Custom middleware list that will be used to
70+
create a middleware pipeline. The middleware should be arranged in the order in which
71+
they will modify the request.
72+
Defaults to None,
73+
api_version (APIVersion): The Graph API version to be used.
7174
Defaults to APIVersion.v1.
72-
client (httpx.AsyncClient): The httpx.AsyncClient instance to be used.
73-
Defaults to KiotaClientFactory.get_default_client().
74-
host (NationalClouds): The national clound endpoint to be used.
75+
This is only used if the client parameter is None.
76+
client (Optional[httpx.AsyncClient]): The httpx.AsyncClient instance to be used.
77+
Defaults to None.
78+
When None, a client will be created with base url set to https://{host}/{api_version}.
79+
host (NationalClouds): The national cloud endpoint to be used.
7580
Defaults to NationalClouds.Global.
81+
This is only used if the client parameter is None.
7682
"""
7783
if client is None:
7884
client = KiotaClientFactory.get_default_client()
79-
client.base_url = GraphClientFactory._get_base_url(host, api_version) # type: ignore
85+
client.base_url = GraphClientFactory._get_base_url(host, api_version)
86+
8087
return GraphClientFactory._load_middleware_to_client(client, middleware)
8188

8289
@staticmethod

src/msgraph_core/requests/batch_request_item.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import json
44
import re
55
import urllib.request
6-
from deprecated import deprecated
76
from io import BytesIO
87
from typing import Any, Optional, Union
98
from urllib.parse import urlparse
109
from uuid import uuid4
10+
from deprecated import deprecated
1111

1212
from kiota_abstractions.headers_collection import HeadersCollection as RequestHeaders
1313
from kiota_abstractions.method import Method

0 commit comments

Comments
 (0)