'create( self, trans, history_id, payload, **kwd )
* POST /api/histories/{history_id}/contents/{type}
create a new HDA by copying an accessible LibraryDataset
:type   history_id: str
:param  history_id: encoded id string of the new HDA\'s History
:type   type: str
:param  type: Type of history content - \'dataset\' (default) or
\'dataset_collection\'.
:type   payload:    dict
:param  payload:    dictionary structure containing::
copy from library (for type \'dataset\'):
\'source\'    = \'library\'
\'content\'   = [the encoded id from the library dataset]
copy from library folder
\'source\'    = \'library_folder\'
\'content\'   = [the encoded id from the library folder]
copy from history dataset (for type \'dataset\'):
\'source\'    = \'hda\'
\'content\'   = [the encoded id from the HDA]
copy from history dataset collection (for type \'dataset_collection\')
\'source\'    = \'hdca\'
\'content\'   = [the encoded id from the HDCA]
create new history dataset collection (for type \'dataset_collection\')
\'source\'              = \'new_collection\' (default \'source\' if type is
\'dataset_collection\' - no need to specify this)
\'collection_type\'     = For example, "list", "paired", "list:paired".
\'name\'                = Name of new dataset collection.
\'element_identifiers\' = Recursive list structure defining collection.
Each element must have \'src\' which can be
\'hda\', \'ldda\', \'hdca\', or \'new_collection\',
as well as a \'name\' which is the name of
element (e.g. "forward" or "reverse" for
paired datasets, or arbitrary sample names
for instance for lists). For all src\'s except
\'new_collection\' - a encoded \'id\' attribute
must be included wiht element as well.
\'new_collection\' sources must defined a
\'collection_type\' and their own list of
(potentially) nested \'element_identifiers\'.
..note:
Currently, a user can only copy an HDA from a history that the user owns.
:rtype:     dict
:returns:   dictionary containing detailed information for the new HDA'

@expose_api_anonymous
def create(self, trans, history_id, payload, **kwd):

    history = self.history_manager.get_owned(self.decode_id(history_id), trans.user, current_history=trans.history)
    type = payload.get('type', 'dataset')
    if (type == 'dataset'):
        source = payload.get('source', None)
        if (source == 'library_folder'):
            return self.__create_datasets_from_library_folder(trans, history, payload, **kwd)
        else:
            return self.__create_dataset(trans, history, payload, **kwd)
    elif (type == 'dataset_collection'):
        return self.__create_dataset_collection(trans, history, payload, **kwd)
    else:
        return self.__handle_unknown_contents_type(trans, type)
