#NEWLINE# def get_objects( vim , type_ , max_objects , properties_to_collect = None , all_properties = False ) : #NEWLINE# #INDENT# "Get all managed object references of the given type.\n\n    It is the caller's responsibility to continue or cancel retrieval.\n\n    :param vim: Vim object\n    :param type_: type of the managed object\n    :param max_objects: maximum number of objects that should be returned in\n                        a single call\n    :param properties_to_collect: names of the managed object properties to be\n                                  collected\n    :param all_properties: whether all properties of the managed object need to\n                           be collected\n    :returns: all managed object references of the given type\n    :raises: VimException, VimFaultException, VimAttributeException,\n             VimSessionOverLoadException, VimConnectionException\n    " #NEWLINE# if ( not properties_to_collect ) : #NEWLINE# #INDENT# properties_to_collect = [ 'name' ] #NEWLINE# #UNINDENT# client_factory = vim . client . factory #NEWLINE# recur_trav_spec = build_recursive_traversal_spec ( client_factory ) #NEWLINE# object_spec = build_object_spec ( client_factory , vim . service_content . rootFolder , [ recur_trav_spec ] ) #NEWLINE# property_spec = build_property_spec ( recur_trav_spec , type_ = type_ , properties_to_collect = properties_to_collect , all_properties = all_properties ) #NEWLINE# property_filter_spec = build_property_filter_spec ( client_factory , [ property_spec ] , [ object_spec ] ) #NEWLINE# options = client_factory . create ( 'ns0:RetrieveOptions' ) #NEWLINE# options . maxObjects = max_objects #NEWLINE# return vim . RetrievePropertiesEx ( vim . service_content . propertyCollector , specSet = [ property_filter_spec ] , options = options )