@@ -391,15 +391,16 @@ def object_json(self, ignore_not_found=False):
391391
392392 return r .out ()
393393
394- def object (self , ignore_not_found = False ):
394+ def object (self , ignore_not_found = False , cls = None ):
395395 """
396396 Returns a single APIObject that represents the selected resource. If multiple
397397 resources are being selected an exception will be thrown (use objects() when
398398 there is a possibility of selecting multiple objects).
399399 :param ignore_not_found: If True and no object exists, None will be returned instead of an exception.
400+ :param cls: Custom APIObject class to return
400401 :return: A Model of the selected resource.
401402 """
402- objs = self .objects ()
403+ objs = self .objects (cls = cls )
403404 if len (objs ) == 0 :
404405 if ignore_not_found :
405406 return None
@@ -409,17 +410,24 @@ def object(self, ignore_not_found=False):
409410
410411 return objs [0 ]
411412
412- def objects (self , ignore_not_found = True ):
413+ def objects (self , ignore_not_found = True , cls = None ):
413414 """
414415 Returns a python list of APIObject objects that represent the selected resources. An
415416 empty is returned if nothing is selected.
416417 :param ignore_not_found: If true, missing named resources will not raise an exception.
418+ :param cls: Custom APIObject class to return
417419 :return: A list of Model objects representing the receiver's selected resources.
418420 """
419421 from .apiobject import APIObject
420422
421423 obj = json .loads (self .object_json (ignore_not_found = ignore_not_found ))
422- return APIObject (obj ).elements ()
424+
425+ if cls is not None :
426+ api_objects = cls (obj ).elements (cls )
427+ else :
428+ api_objects = APIObject (obj ).elements ()
429+
430+ return api_objects
423431
424432 def start_build (self , cmd_args = None ):
425433 r = Selector ('start_build' )
0 commit comments