#!/usr/bin/env python

"""
Step 4
======
In this step, we'll create a new history named 'Step 4' and get the hdas
inside it (which will sadly be an empty list since it's new).
"""
import os
import sys
import pprint

import users_1
import histories_3
# note: that we're using the new hdas module for this step
import hdas_1

NEW_HISTORY_NAME = 'Step 4'

# ----------------------------------------------------------------------------- main
if __name__ == '__main__':
    try:
        # check the connection
        users = users_1.get_users()

        # create a new history
        new_history = histories_3.create_history( NEW_HISTORY_NAME )
        print 'created history!', new_history[ 'name' ]
        new_history_id = new_history[ 'id' ]
        new_history_details = histories_3.get_history( new_history_id )

        # get the (empty) list of hdas inside that history
        hdas = hdas_1.get_hdas( new_history[ 'id' ] )
        
    except Exception, exc:
        print 'Error getting HDAs:', str( exc )
        sys.exit( 1 )

    print 'HDAs:'
    pprint.pprint( hdas, indent=2 )
