def make_endpoint(model):
    """Make an endpoint for a given model

    See the :class:`repose.resources.Resource.Meta` for a description
    of endpoint URL formatting.
    """
    parent = model.parent_resource
    models = [model]
    while parent:
        models.append(parent)
        parent = parent.parent_resource
    values = {}
    for inst in models:
        for k in inst._fields:
            values['{}_{}'.format(inst.__class__.__name__.lower(), k)
                ] = getattr(inst, k)
            if inst is model:
                values[k] = getattr(inst, k)
    values.update(**model.get_endpoint_values())
    return model.Meta.endpoint.format(**values)
