From 77603a47a11fb8bb7a7720b8180331e906c52b2b Mon Sep 17 00:00:00 2001 From: shemogumbe Date: Tue, 8 Oct 2024 15:17:17 +0300 Subject: [PATCH 1/4] fix add event with depends on --- src/msgraph_core/requests/batch_request_content.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/msgraph_core/requests/batch_request_content.py b/src/msgraph_core/requests/batch_request_content.py index 9a48ef0f..8e99d69c 100644 --- a/src/msgraph_core/requests/batch_request_content.py +++ b/src/msgraph_core/requests/batch_request_content.py @@ -52,7 +52,7 @@ def add_request(self, request_id: Optional[str], request: BatchRequestItem) -> N request.id = str(uuid.uuid4()) if hasattr(request, 'depends_on') and request.depends_on: for dependent_id in request.depends_on: - if dependent_id not in [req.id for req in self.requests]: + if dependent_id not in self.requests: dependent_request = self._request_by_id(dependent_id) if dependent_request: self._requests[dependent_id] = dependent_request From 5711d4f214209f1c1b9caff6a899b32cbeb79ca1 Mon Sep 17 00:00:00 2001 From: shemogumbe Date: Tue, 8 Oct 2024 16:36:22 +0300 Subject: [PATCH 2/4] Enable batch request with content collection --- src/msgraph_core/requests/batch_request_builder.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/msgraph_core/requests/batch_request_builder.py b/src/msgraph_core/requests/batch_request_builder.py index 608876f0..bb8afaa6 100644 --- a/src/msgraph_core/requests/batch_request_builder.py +++ b/src/msgraph_core/requests/batch_request_builder.py @@ -108,6 +108,11 @@ async def _post_batch_collection( for batch_request_content in batch_request_content_collection.batches: request_info = await self.to_post_request_information(batch_request_content) + bytes_content = request_info.content + json_content = bytes_content.decode("utf-8") + updated_str = '{"requests":' + json_content + '}' + updated_bytes = updated_str.encode("utf-8") + request_info.content = updated_bytes response = await self._request_adapter.send_async( request_info, BatchResponseContent, error_map or self.error_map ) From 765dbfeaa05fc21195c380a9c857cdf9e582d006 Mon Sep 17 00:00:00 2001 From: Musale Martin Date: Mon, 18 Nov 2024 14:44:41 +0300 Subject: [PATCH 3/4] Remove request wrapping in batch collection POST --- src/msgraph_core/requests/batch_request_builder.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/msgraph_core/requests/batch_request_builder.py b/src/msgraph_core/requests/batch_request_builder.py index bb8afaa6..57c0e465 100644 --- a/src/msgraph_core/requests/batch_request_builder.py +++ b/src/msgraph_core/requests/batch_request_builder.py @@ -106,16 +106,8 @@ async def _post_batch_collection( batch_responses = BatchResponseContentCollection() - for batch_request_content in batch_request_content_collection.batches: - request_info = await self.to_post_request_information(batch_request_content) - bytes_content = request_info.content - json_content = bytes_content.decode("utf-8") - updated_str = '{"requests":' + json_content + '}' - updated_bytes = updated_str.encode("utf-8") - request_info.content = updated_bytes - response = await self._request_adapter.send_async( - request_info, BatchResponseContent, error_map or self.error_map - ) + for batch_request_content in batch_request_content_collection.get_batch_requests_for_execution(): + response = await self.post(batch_request_content, error_map) batch_responses.add_response(response) return batch_responses From 0289e2f6c4aa185d9baa369fe995a7307b90d9b1 Mon Sep 17 00:00:00 2001 From: Musale Martin Date: Mon, 18 Nov 2024 14:53:53 +0300 Subject: [PATCH 4/4] Fix failing formatting --- src/msgraph_core/requests/batch_request_builder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/msgraph_core/requests/batch_request_builder.py b/src/msgraph_core/requests/batch_request_builder.py index 57c0e465..0c238b8d 100644 --- a/src/msgraph_core/requests/batch_request_builder.py +++ b/src/msgraph_core/requests/batch_request_builder.py @@ -105,8 +105,8 @@ async def _post_batch_collection( raise ValueError("batch_request_content_collection cannot be Null.") batch_responses = BatchResponseContentCollection() - - for batch_request_content in batch_request_content_collection.get_batch_requests_for_execution(): + batch_requests = batch_request_content_collection.get_batch_requests_for_execution() + for batch_request_content in batch_requests: response = await self.post(batch_request_content, error_map) batch_responses.add_response(response)