Esempio n. 1
0
def do_list_part(config):
    """
    Lists out all the state associating with the UUIDs in the
    Transaction Family : Part
    
    Args:
        config (ConfigParser): ConfigParser which contains the default url
    
    Returns:
        type: str
        String representing JSON object which allows the client to know that
        the call was either a success or a failure.
    
    Raises:
        PartException:
            * If failed to retrieve the list
            
    """
    b_url = config.get("DEFAULT", "url")
    client = PartBatch(base_url=b_url)
    result = client.list_part()

    if result is not None:
        result.sort(key=lambda x:x["timestamp"], reverse=True)
        result = json.dumps(result)
        
        output = ret_msg("success", "OK", "ListOf:PartRecord", result)
        
        print(output)
    else:
        raise PartException("Could not retrieve part listing.")
Esempio n. 2
0
def do_list_part(args, config):
    url = config.get('DEFAULT', 'url')

    client = PartBatch(base_url=url)
    result = client.list_part()

    if result is not None:
        result = refine_output(str(result))
        output = ret_msg("success", "OK", "ListOf:PartRecord", result)
        print(output)
    else:
        raise PartException("Could not retrieve part listing.")
Esempio n. 3
0
def do_list_part(args, config):
    url = config.get('DEFAULT', 'url')
    key_file = config.get('DEFAULT', 'key_file')
    auth_user, auth_password = _get_auth_info(args)

    client = PartBatch(base_url=url, keyfile=key_file)

    result = client.list_part(auth_user=auth_user, auth_password=auth_password)

    if result is not None:
        output = refine_output(str(result))
        print(output)
    else:
        raise PartException("Could not retrieve part listing.")
Esempio n. 4
0
def api_do_list_part(config):
    """
    API version of "do_list_part" function.
    """
    b_url = config.get("DEFAULT", "url")
    client = PartBatch(base_url=b_url)
    result = client.list_part()

    if result is not None:
        result.sort(key=lambda x: x["timestamp"], reverse=True)
        result = json.dumps(result)

        output = ret_msg("success", "OK", "ListOf:PartRecord", result)

        return output
    else:
        return ret_msg("failed",
                       "PartException : Could not retrieve part listing.",
                       "PartRecord", "{}")