1- from functools import partial
21from typing import Optional , Iterable , Dict , Tuple , Callable , Union , Sequence
32from uuid import UUID
43
@@ -26,6 +25,8 @@ def _fetch_page(self,
2625 per_page : Optional [int ] = None ,
2726 json_body : Optional [dict ] = None ,
2827 additional_params : Optional [dict ] = None ,
28+ * ,
29+ version : Optional [str ] = None
2930 ) -> Tuple [Iterable [dict ], str ]:
3031 """
3132 Fetch visible elements. This does not handle pagination.
@@ -59,6 +60,9 @@ def _fetch_page(self,
5960 }
6061 additional_params: dict, optional
6162 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.
6266
6367 Returns
6468 -------
@@ -69,15 +73,16 @@ def _fetch_page(self,
6973
7074 """
7175 # 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 {}
7579
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 )
7881 params .update (additional_params or {})
7982
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 )
8186
8287 try :
8388 next_uri = data .get ('next' , "" )
0 commit comments