Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 37 additions & 23 deletions backend/python/app/sources/external/microsoft/one_note/one_note.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


import json
import logging
from dataclasses import asdict
Expand Down Expand Up @@ -4072,27 +4070,31 @@ async def groups_onenote_notebooks_sections_update_pages(
"""
# Build query parameters including OData for OneNote
try:
# Use typed query parameters
query_params = RequestConfiguration()
# Set query parameters using typed object properties
if select:
query_params.select = select if isinstance(select, list) else [select]
if expand:
query_params.expand = expand if isinstance(expand, list) else [expand]
if filter:
query_params.filter = filter
if orderby:
query_params.orderby = orderby
if search:
query_params.search = search
if top is not None:
query_params.top = top
if skip is not None:
query_params.skip = skip
# Only create query_params and config if necessary.
any_query_param = select or expand or filter or orderby or search or top is not None or skip is not None
if any_query_param or headers:
query_params = RequestConfiguration()
if select:
# Only use isinstance if type not guaranteed; here it may be, but for API robustness.
query_params.select = select if isinstance(select, list) else [select]
if expand:
query_params.expand = expand if isinstance(expand, list) else [expand]
if filter:
query_params.filter = filter
if orderby:
query_params.orderby = orderby
if search:
query_params.search = search
if top is not None:
query_params.top = top
if skip is not None:
query_params.skip = skip
config = RequestConfiguration()
config.query_parameters = query_params
else:
# No query parameters nor headers - skip constructing unused objects
config = RequestConfiguration()

# Create proper typed request configuration
config = RequestConfiguration()
config.query_parameters = query_params

if headers:
config.headers = headers
Expand All @@ -4103,7 +4105,19 @@ async def groups_onenote_notebooks_sections_update_pages(
config.headers = {}
config.headers['ConsistencyLevel'] = 'eventual'

response = await self.client.groups.by_group_id(group_id).onenote.notebooks.by_notebook_id(notebook_id).sections.by_onenote_section_id(onenoteSection_id).pages.by_onenote_page_id(onenotePage_id).patch(body=request_body, request_configuration=config)
patch_builder = (
self.client.groups
.by_group_id(group_id)
.onenote
.notebooks
.by_notebook_id(notebook_id)
.sections
.by_onenote_section_id(onenoteSection_id)
.pages
.by_onenote_page_id(onenotePage_id)
)
# Avoid extra lookup on potentially long attribute chain for better locality.
response = await patch_builder.patch(body=request_body, request_configuration=config)
return self._handle_onenote_response(response)
except Exception as e:
return OneNoteResponse(
Expand Down