'GET /api/remote_files/
Displays remote files.
:param  target:      target to load available datasets from, defaults to ftp
possible values: ftp, userdir, importdir
:type   target:      str
:param  format:      requested format of data, defaults to flat
possible values: flat, jstree, ajax
:returns:   list of available files
:rtype:     list'

@expose_api
def index(self, trans, **kwd):

    target = kwd.get('target', None)
    format = kwd.get('format', None)
    if (target == 'userdir'):
        user_login = trans.user.email
        user_base_dir = trans.app.config.user_library_import_dir
        if (user_base_dir is None):
            raise exceptions.ConfigDoesNotAllowException('The    configuration    of    this    Galaxy    instance    does    not    allow    upload    from    user    directories.')
        full_import_dir = os.path.join(user_base_dir, user_login)
        if (not os.path.exists(full_import_dir)):
            raise exceptions.ObjectNotFound('You    do    not    have    any    files    in    your    user    directory.    Use    FTP    to    upload    there.')
        if (full_import_dir is not None):
            if (format == 'jstree'):
                disable = kwd.get('disable', 'folders')
                try:
                    userdir_jstree = self.__create_jstree(full_import_dir, disable)
                    response = userdir_jstree.jsonData()
                except Exception as exception:
                    log.debug(str(exception))
                    raise exceptions.InternalServerError(('Could    not    create    tree    representation    of    the    given    folder:    ' + str(full_import_dir)))
                if (not response):
                    raise exceptions.ObjectNotFound('You    do    not    have    any    files    in    your    user    directory.    Use    FTP    to    upload    there.')
            elif (format == 'ajax'):
                raise exceptions.NotImplemented('Not    implemented    yet.    Sorry.')
            else:
                try:
                    response = self.__load_all_filenames(full_import_dir)
                except Exception as exception:
                    log.error('Could    not    get    user    import    files:    %s', str(exception), exc_info=True)
                    raise exceptions.InternalServerError('Could    not    get    the    files    from    your    user    directory    folder.')
        else:
            raise exceptions.InternalServerError('Could    not    get    the    files    from    your    user    directory    folder.')
    elif (target == 'importdir'):
        base_dir = trans.app.config.library_import_dir
        if (base_dir is None):
            raise exceptions.ConfigDoesNotAllowException('The    configuration    of    this    Galaxy    instance    does    not    allow    usage    of    import    directory.')
        if (format == 'jstree'):
            disable = kwd.get('disable', 'folders')
            try:
                importdir_jstree = self.__create_jstree(base_dir, disable)
                response = importdir_jstree.jsonData()
            except Exception as exception:
                log.debug(str(exception))
                raise exceptions.InternalServerError(('Could    not    create    tree    representation    of    the    given    folder:    ' + str(base_dir)))
        elif (format == 'ajax'):
            raise exceptions.NotImplemented('Not    implemented    yet.    Sorry.')
        else:
            try:
                response = self.__load_all_filenames(base_dir)
            except Exception as exception:
                log.error('Could    not    get    user    import    files:    %s', str(exception), exc_info=True)
                raise exceptions.InternalServerError('Could    not    get    the    files    from    your    import    directory    folder.')
    else:
        user_ftp_base_dir = trans.app.config.ftp_upload_dir
        if (user_ftp_base_dir is None):
            raise exceptions.ConfigDoesNotAllowException('The    configuration    of    this    Galaxy    instance    does    not    allow    upload    from    FTP    directories.')
        try:
            user_ftp_dir = trans.user_ftp_dir
            if (user_ftp_dir is not None):
                response = self.__load_all_filenames(user_ftp_dir)
            else:
                log.warning('You    do    not    have    an    FTP    directory    named    as    your    login    at    this    Galaxy    instance.')
                return None
        except Exception as exception:
            log.warning('Could    not    get    ftp    files:    %s', str(exception), exc_info=True)
            return None
    return response
