# This is a simple example of how to call the Awasu API.

import sys
import awasu_api

# initialize
API_URL = "http://localhost:2604"
API_TOKEN = None
apiArgs = {} # nb: list of "key=val" values to pass into the API call
postData = None # some API calls expect data to be passed in
rawMode = False # set this to True if you want to see the raw response sent back by Awasu

# call the Awasu API
awasuApi = awasu_api.AwasuApi( API_URL , API_TOKEN )
responseHeaders,responseBody = awasuApi.callApi( "stats" , apiArgs , postData , rawMode , True )

# output the response
print responseHeaders 
print 
if rawMode :
    # just output the raw response 
    print responseBody
else :
    # output a formatted dump of the XML response 
    if type(responseBody) is str :
        print responseBody 
    else :
        awasu_api.dumpXmlTree( responseBody )
