import requests
import yaml


def current_versions(string='all'):
    """Get curent versions of hosted datasets from BTK API."""
    btk = "https://blobtoolkit.genomehubs.org/api/v1/search/%s" % string
    response = requests.get(btk)
    current = {}
    if response.ok:
        data = yaml.full_load(response.text)
        for asm in data:
            if 'version' in asm:
                current.update({asm['prefix']: asm['version']})
            else:
                current.update({asm['prefix']: 1})
    return current