
def get_records(base_url, http_get, data_record, target, **kwargs):
    url = _graphite_url_for_target(base_url, target, **kwargs)
    resp = http_get(url, verify=True)
    resp.raise_for_status()
    records = []
    for line in resp.content.split('\n'):
        if line:
            record = data_record(line)
            records.append(record)
    return records


def _graphite_url_for_target(base, target, from_='-1min', until_=None):
    url = '{0}/render/?target={1}&rawData=true&from={2}'.format(
        base,
        target,
        from_
    )
    if until_:
        url += '&until={1}'.format(until_)
    return url


def get_records(base_url, http_get, data_record, target, **kwargs):
    url = _graphite_url_for_target(base_url, target, **kwargs)
    resp = http_get(url, verify=True)
    resp.raise_for_status()
    records = []
    for line in resp.content.split('\n'):
        if line:
            record = data_record(line)
            records.append(record)
    return records


def _graphite_url_for_target(base, target, from_='-1min', until_=None):
    url = '{0}/render/?target={1}&rawData=true&from={2}'.format(
        base,
        target,
        from_
    )
    if until_:
        url += '&until={0}'.format(until_)
    return url

fix until: