From fb79fce73422b1eb42afd4ea1342538018dac66f Mon Sep 17 00:00:00 2001 From: shemogumbe Date: Wed, 2 Oct 2024 13:04:27 +0300 Subject: [PATCH 1/4] added batch to graph cient --- msgraph/graph_service_client.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/msgraph/graph_service_client.py b/msgraph/graph_service_client.py index c9a015c3c97..7491836828f 100644 --- a/msgraph/graph_service_client.py +++ b/msgraph/graph_service_client.py @@ -17,7 +17,9 @@ if TYPE_CHECKING: from .generated.users.item.user_item_request_builder import UserItemRequestBuilder + class GraphServiceClient(BaseGraphServiceClient): + def __init__( self, credentials: Optional[Union[TokenCredential, AsyncTokenCredential]] = None, @@ -60,3 +62,12 @@ def me(self) -> UserItemRequestBuilder: url_tpl_parameters["user%2Did"] = "me-token-to-replace" return UserItemRequestBuilder(self.request_adapter, url_tpl_parameters) + + @property + def batch(self) -> BatchRequestBuilder: + """ + Returns a BatchRequestBuilder to enable batch requests. + """ + from msgraph_core.requests.batch_request_builder import BatchRequestBuilder + + return BatchRequestBuilder(self.request_adapter) From a794f65d90c5258f5e0debe719ab719c2011bd1b Mon Sep 17 00:00:00 2001 From: shemogumbe Date: Wed, 2 Oct 2024 17:06:12 +0300 Subject: [PATCH 2/4] use latest msgraph_core --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 35df36d62e7..9fdaa2b1b14 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -42,7 +42,7 @@ microsoft-kiota-serialization-multipart==0.1.0 microsoft-kiota-serialization-text==1.0.0 msal==1.30.0 msal-extensions==1.2.0 -msgraph-core==1.1.2 +msgraph-core==1.1.5 multidict==6.0.5 mypy==1.11.2 mypy-extensions==1.0.0 From 08f581c1401fa4972a49c30b123b4d539a8b2bf7 Mon Sep 17 00:00:00 2001 From: shemogumbe Date: Wed, 2 Oct 2024 17:11:23 +0300 Subject: [PATCH 3/4] clean up code --- msgraph/graph_service_client.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/msgraph/graph_service_client.py b/msgraph/graph_service_client.py index 7491836828f..e948e16d76e 100644 --- a/msgraph/graph_service_client.py +++ b/msgraph/graph_service_client.py @@ -9,7 +9,6 @@ from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential from kiota_authentication_azure.azure_identity_authentication_provider import AzureIdentityAuthenticationProvider -from httpx import AsyncClient from .generated.base_graph_service_client import BaseGraphServiceClient from .graph_request_adapter import GraphRequestAdapter @@ -64,7 +63,7 @@ def me(self) -> UserItemRequestBuilder: return UserItemRequestBuilder(self.request_adapter, url_tpl_parameters) @property - def batch(self) -> BatchRequestBuilder: + def batch(self) -> 'BatchRequestBuilder': """ Returns a BatchRequestBuilder to enable batch requests. """ From 493f6e96c452f9f6e9666891e6b44149f42edb5c Mon Sep 17 00:00:00 2001 From: shemogumbe Date: Wed, 2 Oct 2024 17:17:41 +0300 Subject: [PATCH 4/4] remove defered import for BatchRequestBuilder --- msgraph/graph_service_client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/msgraph/graph_service_client.py b/msgraph/graph_service_client.py index e948e16d76e..24513424232 100644 --- a/msgraph/graph_service_client.py +++ b/msgraph/graph_service_client.py @@ -15,6 +15,7 @@ if TYPE_CHECKING: from .generated.users.item.user_item_request_builder import UserItemRequestBuilder + from msgraph_core.requests.batch_request_builder import BatchRequestBuilder class GraphServiceClient(BaseGraphServiceClient): @@ -63,7 +64,7 @@ def me(self) -> UserItemRequestBuilder: return UserItemRequestBuilder(self.request_adapter, url_tpl_parameters) @property - def batch(self) -> 'BatchRequestBuilder': + def batch(self) -> BatchRequestBuilder: """ Returns a BatchRequestBuilder to enable batch requests. """