import requests
import json


def get_results_list(hda_dict):
    """ 
    Generates a list of filenames to be available for download
    
    Parameters:
        hda_dict: dictionary initied with the function init, that 
                  stores all required information to be able to interact
                  with the HDA API

    Returns:
        Returns the dictionary including the list of filenames to be 
        downloaded.
    """
    params = {'page':'0', 'size':'1'}
    response = requests.get(hda_dict['broker_endpoint'] + \
               '/datarequest/jobs/' + hda_dict['job_id'] + \
               '/result', headers=hda_dict['headers'], params = params)
    results = json.loads(response.text)
    hda_dict['results']=results

    print("************** Results *******************************")
    print(json.dumps(results, indent=4, sort_keys=True))
    print("*******************************************")
    
    return hda_dict