@@ -480,10 +480,22 @@ def count(cls, **kwargs) -> int:
480480
481481 @classmethod
482482 def _get_all_objects (
483- cls , offset : int | None , count : int | None , ** kwargs
483+ cls ,
484+ offset : int | None ,
485+ count : int | None ,
486+ endpoint : str | None = None ,
487+ expected_type : type = dict ,
488+ ** kwargs ,
484489 ) -> Generator [dict , None , None ]:
485490 _class_instance = cls (_read_only = True )
486- _url = f"{ _class_instance ._base_url } "
491+
492+ # Allow the possibility of paginating a URL that is not the
493+ # main class endpoint
494+ _url = (
495+ f"{ _class_instance ._user_config .server .url } /{ endpoint } "
496+ if endpoint
497+ else f"{ _class_instance ._base_url } "
498+ )
487499
488500 _label = _class_instance .__class__ .__name__ .lower ()
489501 if _label .endswith ("s" ):
@@ -492,12 +504,18 @@ def _get_all_objects(
492504 for response in get_paginated (
493505 _url , headers = _class_instance ._headers , offset = offset , count = count , ** kwargs
494506 ):
495- yield get_json_from_response (
507+ _generator = get_json_from_response (
496508 response = response ,
497509 expected_status = [http .HTTPStatus .OK ],
498510 scenario = f"Retrieval of { _label } s" ,
511+ expected_type = expected_type ,
499512 ) # type: ignore
500513
514+ if expected_type is dict :
515+ yield _generator
516+ else :
517+ yield from _generator
518+
501519 def read_only (self , is_read_only : bool ) -> None :
502520 """Set whether this object is in read only state.
503521
@@ -535,7 +553,7 @@ def commit(self) -> dict | list[dict] | None:
535553 # If batch upload send as list, else send as dictionary of params
536554 if _batch_commit := self ._staging .get ("batch" ):
537555 self ._logger .debug (
538- f"Posting batched data to server: \n { json . dumps (_batch_commit , indent = 2 ) } "
556+ f"Posting batched data to server: { len (_batch_commit ) } { self . _label } s "
539557 )
540558 _response = self ._post_batch (batch_data = _batch_commit )
541559 else :
@@ -612,19 +630,16 @@ def _post_batch(
612630 return _json_response
613631
614632 def _post_single (
615- self ,
616- * ,
617- is_json : bool = True ,
618- ** kwargs ,
633+ self , * , is_json : bool = True , data : list | dict | None = None , ** kwargs
619634 ) -> dict [str , typing .Any ] | list [dict [str , typing .Any ]]:
620635 if not is_json :
621- kwargs = msgpack .packb (kwargs , use_bin_type = True )
636+ kwargs = msgpack .packb (data or kwargs , use_bin_type = True )
622637
623638 _response = sv_post (
624639 url = f"{ self ._base_url } " ,
625640 headers = self ._headers | {"Content-Type" : "application/msgpack" },
626641 params = self ._params ,
627- data = kwargs ,
642+ data = data or kwargs ,
628643 is_json = is_json ,
629644 )
630645
0 commit comments