A Way to get all list values for a CollectionResponse?
@jussihi arbeitet bereits daran.
Seit 08.10.2024.
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
Is your feature request related to a problem? Please describe the problem.
Is there already a way to get all items for a CollectionResponse? Currently the API/SDK returns only a page of results, and then we need to fetch more by using odata_next_link.
Is there a way to get all results in a single request?
I have made a helper function which I use, is this the best way;
# Takes in any CollectionResponse
async def get_complete_paginated_list(
request_builder_func: Any,
request_configuration: Optional[Any] = None
) -> List[Any]:
ret: List[Any] = []
collection_response: Any = await request_builder_func.get()
# Nothing to return here
if collection_response is None or collection_response.value is None:
return ret
def add_response_items(response: Optional[Any], items: List[Any]) -> None:
if response is not None and response.value is not None:
for item in response.value:
items.append(item)
# Add initial results
add_response_items(collection_response, ret)
# Iterate pages
while collection_response is not None and collection_response.odata_next_link is not None:
collection_response: Optional[Any] = await request_builder_func.with_url(collection_response.odata_next_link).get(request_configuration = request_configuration)
if collection_response is not None:
add_response_items(collection_response, ret)
return ret
It can then be used like this;
mailfolders: List[MailFolder] = await get_complete_paginated_list(graph_client.users.by_user_id(user_id).mail_folders)
Describe the solution you'd like.
something like what I've made
Additional context?
No response
- Vorherrschende Sprache
- Python
- Sterne
- 630
- Forks
- 96
- Ø Merge
- 15 Std. 20 Min.
- Gemergte PRs (30 T.)
- 3
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microsoftgraph/msgraph-sdk-python
-
status:waiting-for-triage type:bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
microsoftgraph/msgraph-sdk-python#1570 ·
-
status:waiting-for-triage type:bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
microsoftgraph/msgraph-sdk-python#1563 ·
-
Needs: Attention :wave: type:bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
microsoftgraph/msgraph-sdk-python#1287 · 2 Kommentare · 1 Reaktion ·
-
Batch Request Support Offenstatus:waiting-for-triage
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
microsoftgraph/msgraph-sdk-python#1557 ·
-
status:waiting-for-triage type:bug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
microsoftgraph/msgraph-sdk-python#1556 · 1 Kommentar · 1 Reaktion ·
Alle Issues in microsoftgraph/msgraph-sdk-python
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
zostera/django-bootstrap4#894 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
use-agent-os/agent-os#3276 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
NousResearch/hermes-agent#117848 ·