Exemplo n.º 1
0
def api_do_retrieve_part(pt_id, config, all_flag=False, range_flag=None):
    """
    API version of "do_retrieve_part" function.
    """
    if range_flag != None:
        all_flag = True
    
    b_url = config.get("DEFAULT", "url")
    client = PartBatch(base_url=b_url)
    data = client.retrieve_part(pt_id, all_flag, range_flag)
    
    if data is not None:
        
        if all_flag == False:
            output = ret_msg("success", "OK", "PartRecord", data.decode())
        else:
            if range_flag == None:
                output = ret_msg("success", "OK", "PartRecord", data)
            else:
                if len(data) != 0:
                    output = ret_msg(
                        "success", "OK", "PartRecord", json.dumps(data[0])
                    )
                else:
                    output = ret_msg("success", "OK", "PartRecord", "{}")
            
        return output
    else:
        return ret_msg(
                    "failed",
                    "PartException : UUID {} does not exist." \
                    .format(pt_id),
                    "PartRecord", "{}"
                )
Exemplo n.º 2
0
def do_retrieve(args, config):

    pt_id = args.pt_id

    url = config.get('DEFAULT', 'url')

    client = PartBatch(base_url=url)

    result = client.retrieve_part(pt_id).decode()

    if result is not None:
        result = filter_output(str(result))
        output = ret_msg("success", "OK", "PartRecord", result)
        print(result)

    else:
        raise PartException("Part not found: {}".format(pt_id))
Exemplo n.º 3
0
def do_retrieve_part(args, config):
    """
    Retrieves the state associating with the UUID in the
    Transaction Family : Part
    
    Args:
        args (ArgumentParser):
            ArgumentParser object containing required parameters
        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 uuid
    
    """
    all_flag = args.all
    range_flag = args.range
    
    pt_id = args.pt_id
    
    if range_flag != None:
        all_flag = True
    
    b_url = config.get("DEFAULT", "url")
    client = PartBatch(base_url=b_url)
    data = client.retrieve_part(pt_id, all_flag, range_flag)
    
    if data is not None:
        
        if all_flag == False:
            output = ret_msg("success", "OK", "PartRecord", data.decode())
        else:
            output = ret_msg("success", "OK", "PartRecord", data)
            
        print(output)
    else:
        raise PartException("Part not found: {}".format(pt_id))
Exemplo n.º 4
0
def do_retrieve(args, config):

    pt_id = args.pt_id

    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.retrieve_part(pt_id,
                                  auth_user=auth_user,
                                  auth_password=auth_password).decode()

    if result is not None:
        result = filter_output(str(result))
        print(result)

    else:
        raise PartException("Part not found: {}".format(pt_id))