1
- from functools import partial
2
1
from typing import Optional , Iterable , Dict , Tuple , Callable , Union , Sequence
3
2
from uuid import UUID
4
3
@@ -26,6 +25,8 @@ def _fetch_page(self,
26
25
per_page : Optional [int ] = None ,
27
26
json_body : Optional [dict ] = None ,
28
27
additional_params : Optional [dict ] = None ,
28
+ * ,
29
+ version : Optional [str ] = None
29
30
) -> Tuple [Iterable [dict ], str ]:
30
31
"""
31
32
Fetch visible elements. This does not handle pagination.
@@ -59,6 +60,9 @@ def _fetch_page(self,
59
60
}
60
61
additional_params: dict, optional
61
62
A dict that allows extra parameters to be added to the request parameters
63
+ version: str, optional
64
+ A string denoting which version of the underlying API endpoint will be called. Defaults
65
+ to the collection's API version.
62
66
63
67
Returns
64
68
-------
@@ -69,15 +73,16 @@ def _fetch_page(self,
69
73
70
74
"""
71
75
# To avoid setting defaults -> reduce mutation risk, and to make more extensible
72
- path = self ._get_path () if path is None else path
73
- fetch_func = fetch_func or partial ( self .session .get_resource , version = self . _api_version )
74
- json_body = {} if json_body is None else json_body
76
+ path = path or self ._get_path ()
77
+ fetch_func = fetch_func or self .session .get_resource
78
+ json_body = json_body or {}
75
79
76
- module_type = getattr (self , '_module_type' , None )
77
- params = self ._page_params (page , per_page , module_type )
80
+ params = self ._page_params (page , per_page )
78
81
params .update (additional_params or {})
79
82
80
- data = fetch_func (path , params = params , ** json_body )
83
+ version = version or self ._api_version
84
+
85
+ data = fetch_func (path , params = params , version = version , ** json_body )
81
86
82
87
try :
83
88
next_uri = data .get ('next' , "" )
0 commit comments