|
32 | 32 | from copy import deepcopy |
33 | 33 | from dataclasses import is_dataclass |
34 | 34 | from http.client import HTTPResponse |
35 | | -from typing import Any, AsyncGenerator, Dict, List, Optional, Tuple, Union |
| 35 | +from typing import Any, Dict, List, Optional, Tuple, Union |
36 | 36 |
|
37 | 37 | import asyncio_atexit |
38 | 38 | import httpx |
@@ -9465,37 +9465,6 @@ async def rest_delete_async( |
9465 | 9465 | **kwargs, |
9466 | 9466 | ) |
9467 | 9467 |
|
9468 | | - async def rest_get_paginated_async( |
9469 | | - self, uri: str, limit: int = 20, offset: int = 0 |
9470 | | - ) -> AsyncGenerator[Dict[str, Any], None]: |
9471 | | - """ |
9472 | | - Get paginated results asynchronously |
9473 | | -
|
9474 | | - Arguments: |
9475 | | - uri: A URI that returns paginated results |
9476 | | - limit: How many records should be returned per request |
9477 | | - offset: At what record offset from the first should iteration start |
9478 | | -
|
9479 | | - Returns: |
9480 | | - A generator over paginated results |
9481 | | -
|
9482 | | - The limit parameter is set at 20 by default. Using a larger limit results in fewer calls to the service, but if |
9483 | | - responses are large enough to be a burden on the service they may be truncated. |
9484 | | - """ |
9485 | | - prev_num_results = sys.maxsize |
9486 | | - while prev_num_results > 0: |
9487 | | - params = {"offset": offset, "limit": limit} |
9488 | | - page = await self.rest_get_async( |
9489 | | - uri=uri, |
9490 | | - params=params, |
9491 | | - ) |
9492 | | - results = page["results"] if "results" in page else page["children"] |
9493 | | - prev_num_results = len(results) |
9494 | | - |
9495 | | - for result in results: |
9496 | | - offset += 1 |
9497 | | - yield result |
9498 | | - |
9499 | 9468 |
|
9500 | 9469 | async def async_request_hook_httpx(span: Span, request: httpx.Request) -> None: |
9501 | 9470 | """Hook used to encapsulate a span for this library. The request hook is called |
|
0 commit comments