1
1
"""
2
- This module contains the PageIterator class which is used to
2
+ This module contains the PageIterator class which is used to
3
3
iterate over paged responses from a server.
4
4
5
- The PageIterator class provides methods to iterate over the items
5
+ The PageIterator class provides methods to iterate over the items
6
6
in the pages, fetch the next page, convert a response to a page, and
7
7
fetch the next page from the server.
8
8
9
9
The PageIterator class uses the Parsable interface to parse the responses
10
- from the server, the HttpxRequestAdapter class to send requests to the
10
+ from the server, the RequestAdapter class to send requests to the
11
11
server, and the PageResult class to represent the pages.
12
12
13
- This module also imports the necessary types and exceptions from the
13
+ This module also imports the necessary types and exceptions from the
14
14
typing, requests.exceptions, kiota_http.httpx_request_adapter,
15
- kiota_abstractions.method, kiota_abstractions.headers_collection,
15
+ kiota_abstractions.method, kiota_abstractions.headers_collection,
16
16
kiota_abstractions.request_information, kiota_abstractions.serialization.parsable,
17
17
and models modules.
18
18
"""
22
22
from typing import TypeVar
23
23
from requests .exceptions import InvalidURL
24
24
25
- from kiota_http . httpx_request_adapter import HttpxRequestAdapter
25
+ from kiota_abstractions . request_adapter import RequestAdapter
26
26
from kiota_abstractions .method import Method
27
27
from kiota_abstractions .headers_collection import HeadersCollection
28
28
from kiota_abstractions .request_information import RequestInformation
@@ -41,7 +41,7 @@ class PageIterator:
41
41
fetch the next page, and convert a response to a page.
42
42
43
43
Attributes:
44
- request_adapter (HttpxRequestAdapter ): The adapter used to send HTTP requests.
44
+ request_adapter (RequestAdapter ): The adapter used to send HTTP requests.
45
45
pause_index (int): The index at which to pause iteration.
46
46
headers (HeadersCollection): The headers to include in the HTTP requests.
47
47
request_options (list): The options for the HTTP requests.
@@ -50,15 +50,15 @@ class PageIterator:
50
50
has_next (bool): Whether there are more pages to fetch.
51
51
52
52
Methods:
53
- __init__(response: Union[T, list, object], request_adapter: HttpxRequestAdapter ,
54
- constructor_callable: Optional[Callable] = None): Initializes a new instance of
53
+ __init__(response: Union[T, list, object], request_adapter: RequestAdapter ,
54
+ constructor_callable: Optional[Callable] = None): Initializes a new instance of
55
55
the PageIterator class.
56
56
"""
57
57
58
58
def __init__ (
59
59
self ,
60
60
response : Union [T , list , object ],
61
- request_adapter : HttpxRequestAdapter ,
61
+ request_adapter : RequestAdapter ,
62
62
constructor_callable : Optional [Callable ] = None
63
63
):
64
64
self .request_adapter = request_adapter
@@ -96,7 +96,7 @@ def set_headers(self, headers: dict) -> HeadersCollection:
96
96
This method takes a dictionary of headers and adds them to the
97
97
existing headers.
98
98
Args:
99
- headers (dict): A dictionary of headers to add. The keys are the
99
+ headers (dict): A dictionary of headers to add. The keys are the
100
100
header names and the values are the header values.
101
101
"""
102
102
self .headers .add_all (** headers )
@@ -123,7 +123,7 @@ async def iterate(self, callback: Callable) -> None:
123
123
The iteration stops when there are no more pages or the callback
124
124
function returns False.
125
125
Args:
126
- callback (Callable): The function to apply to each item.
126
+ callback (Callable): The function to apply to each item.
127
127
It should take one argument (the item) and return a boolean.
128
128
"""
129
129
while True :
@@ -152,7 +152,7 @@ async def next(self) -> Optional[PageResult]:
152
152
def convert_to_page (response : Union [T , list , object ]) -> PageResult :
153
153
"""
154
154
Converts a response to a PageResult.
155
- This method extracts the 'value' and 'odata_next_link' from the
155
+ This method extracts the 'value' and 'odata_next_link' from the
156
156
response and uses them to create a PageResult.
157
157
Args:
158
158
response (Union[T, list, object]): The response to convert. It can
0 commit comments