File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ from typing import Dict , Generic , List , TypeVar
2
+
3
+ from .utils import ignore_docs
4
+
5
+ T = TypeVar ('T' )
6
+
7
+
8
+ class ListPage (Generic [T ]):
9
+ """A single page of items returned from a list() method."""
10
+
11
+ #: list: List of returned objects on this page
12
+ items : List [T ]
13
+ #: int: Count of the returned objects on this page
14
+ count : int
15
+ #: int: The limit on the number of returned objects offset specified in the API call
16
+ offset : int
17
+ #: int: The offset of the first object specified in the API call
18
+ limit : int
19
+ #: int: Total number of objects matching the API call criteria
20
+ total : int
21
+ #: bool: Whether the listing is descending or not
22
+ desc : bool
23
+
24
+ @ignore_docs
25
+ def __init__ (self , data : Dict ) -> None :
26
+ """Initialize a ListPage instance from the API response data."""
27
+ self .items = data ['items' ] if 'items' in data else []
28
+ self .offset = data ['offset' ] if 'offset' in data else 0
29
+ self .limit = data ['limit' ] if 'limit' in data else 0
30
+ self .count = data ['count' ] if 'count' in data else len (self .items )
31
+ self .total = data ['total' ] if 'total' in data else self .offset + self .count
32
+ self .desc = data ['desc' ] if 'desc' in data else False
You can’t perform that action at this time.
0 commit comments