def _get_bandwidth_price_id(items,
                            hourly=True,
                            no_public=False,
                            location=None):
    """Choose a valid price id for bandwidth."""

    # Prefer pay-for-use data transfer with hourly
    for item in items:

        capacity = float(item.get('capacity', 0))
        # Hourly and private only do pay-as-you-go bandwidth
        if any([utils.lookup(item,
                             'itemCategory',
                             'categoryCode') != 'bandwidth',
                (hourly or no_public) and capacity != 0.0,
                not (hourly or no_public) and capacity == 0.0]):
            continue

        for price in item['prices']:
            if not _matches_billing(price, hourly):
                continue
            if not _matches_location(price, location):
                continue

            return price['id']

    raise SoftLayer.SoftLayerError(
        "Could not find valid price for bandwidth option")
Choose a valid price id for bandwidth.