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
67 changes: 41 additions & 26 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 @@ -6534,38 +6532,55 @@ async def me_onenote_notebooks_section_groups_delete_sections(
"""
# 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

# Create proper typed request configuration
needs_query_params = (
select is not None or expand is not None or filter is not None or orderby is not None or
search is not None or top is not None or skip is not None
)
config = RequestConfiguration()
config.query_parameters = query_params
if needs_query_params:
query_params = RequestConfiguration()
# Use local variables to minimize attribute assignments/checks
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
config.query_parameters = query_params

if headers:
config.headers = headers
config.headers = headers.copy() if isinstance(headers, dict) else dict(headers)

# Add consistency level for search operations in OneNote
if search:
if not config.headers:
if not hasattr(config, 'headers') or config.headers is None:
config.headers = {}
config.headers['ConsistencyLevel'] = 'eventual'
# do not overwrite existing 'ConsistencyLevel'
if 'ConsistencyLevel' not in config.headers:
config.headers['ConsistencyLevel'] = 'eventual'

# Call chain lookup caching for faster repeated requests
delete_endpoint = (
self.client
.me
.onenote
.notebooks
.by_notebook_id(notebook_id)
.section_groups
.by_section_group_id(sectionGroup_id)
.sections
.by_onenote_section_id(onenoteSection_id)
)

response = await self.client.me.onenote.notebooks.by_notebook_id(notebook_id).section_groups.by_section_group_id(sectionGroup_id).sections.by_onenote_section_id(onenoteSection_id).delete(request_configuration=config)
response = await delete_endpoint.delete(request_configuration=config)
return self._handle_onenote_response(response)
except Exception as e:
return OneNoteResponse(
Expand Down