'GET /api/datatypes
Return an object containing upload datatypes.'

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

    datatypes_registry = self._datatypes_registry
    try:
        extension_only = asbool(kwd.get('extension_only', True))
        upload_only = asbool(kwd.get('upload_only', True))
        if extension_only:
            if upload_only:
                return datatypes_registry.upload_file_formats
            else:
                return [ext for ext in datatypes_registry.datatypes_by_extension]
        else:
            rval = []
            for elem in datatypes_registry.datatype_elems:
                if ((not asbool(elem.get('display_in_upload'))) and upload_only):
                    continue
                keys = ['extension', 'description', 'description_url']
                dictionary = {}
                for key in keys:
                    dictionary[key] = elem.get(key)
                extension = elem.get('extension')
                if (extension in datatypes_registry.datatypes_by_extension):
                    composite_files = datatypes_registry.datatypes_by_extension[extension].composite_files
                    if composite_files:
                        dictionary['composite_files'] = [_.dict() for _ in composite_files.itervalues()]
                rval.append(dictionary)
            return rval
    except Exception as exception:
        log.error('could    not    get    datatypes:    %s', str(exception), exc_info=True)
        if (not isinstance(exception, exceptions.MessageException)):
            raise exceptions.InternalServerError(str(exception))
        else:
            raise
