def list_instances(version, acs_access_key_id, private_key, response_format,
                   timestamp, rndguid):
    """
    This method enables the you to retrieve the list of currently active cloud 
    servers.
    """
    
    signature = generate_signature(timestamp, rndguid, private_key)
    url_data = generate_url_data(version, acs_access_key_id, response_format, 
                                 timestamp, rndguid, signature)
    return read_api_url(API_METHOD_URLS['list-instances'], url_data)
def describe_instance(version, acs_access_key_id, private_key, response_format,
                      timestamp, rndguid, instanceid):
    """
    This method enables the you to retrieve the details of a specific Cloud 
    Server.
    """
    
    signature = generate_signature(timestamp, rndguid, private_key)
    url_data = generate_url_data(version, acs_access_key_id, response_format, 
                                 timestamp, rndguid, signature)
    url_data['instanceid'] = instanceid
    return read_api_url(API_METHOD_URLS['describe-instance'], url_data)
def terminate_instance(version, acs_access_key_id, private_key, response_format,
                      timestamp, rndguid, list_instances):
    """
    This method enables the you to retrieve the details of a specific Cloud 
    Server.
    """
    
    signature = generate_signature(timestamp, rndguid, private_key)
    url_data = generate_url_data(version, acs_access_key_id, response_format, 
                                 timestamp, rndguid, signature)
    for index, value in enumerate(list_instances):
        url_data['InstanceId_%s' % (index+1)] = value
        
    return read_api_url(API_METHOD_URLS['terminate-instance'], url_data)
def describe_image(version, acs_access_key_id, private_key, response_format,
                   timestamp, rndguid, imageid=""):
    """
    This method enables the client to retrieve a list of available cloud server 
    images & narrow the listing down optionally by a specific image.
    """
    
    signature = generate_signature(timestamp, rndguid, private_key)
    url_data = generate_url_data(version, acs_access_key_id, response_format, 
                                 timestamp, rndguid, signature)
    #add additional params
    if imageid:
        url_data['imageid'] = imageid
    return read_api_url(API_METHOD_URLS['describe-images'], url_data)
def run_instance(version, acs_access_key_id, private_key, response_format,
                 timestamp, rndguid, planname, imageid, server_qty, 
                 servername):
    """
    This method enables you to create new Cloud Servers by specifying a flexible 
    set of configuration parameters.
    """
    signature = generate_signature(timestamp, rndguid, private_key)
    url_data = generate_url_data(version, acs_access_key_id, response_format, 
                                 timestamp, rndguid, signature)
    url_data['planname'] = planname
    url_data['imageid'] = imageid
    url_data['server_qty'] = server_qty
    url_data['servername'] = servername
    
    return read_api_url(API_METHOD_URLS['run-instance'], url_data)
def describe_available_plan(version, acs_access_key_id, private_key, 
                            response_format, timestamp, rndguid, plan_name, 
                            platform):
    
    """
    This method enables the client to retrieve a list of available cloud server 
    plans & narrow the listing down optionally by server platform (windows, 
    linux, etc ) or get information about just one specific plan (e.g. extra 
    small plan XXS)
    """    
    
    signature = generate_signature(timestamp, rndguid, private_key)
    url_data = generate_url_data(version, acs_access_key_id, response_format, 
                                 timestamp, rndguid, signature)
    
    #add additional params
    url_data['plan_name'] = plan_name
    url_data['platform'] = platform
    
    return read_api_url(API_METHOD_URLS['describe-plan'], url_data)