def get_replicas_for_endpoint(coriolis, endpoint,
                              as_source=True, as_target=True):
    """ Returns all Replicas with the given endpoint as source/target. """
    endpoint = coriolis.endpoints.get(endpoint)

    found = []
    for replica in coriolis.replicas.list():
        if as_source and replica.origin_endpoint_id == endpoint.id:
            found.append(replica)

        if as_target and replica.destination_endpoint_id == endpoint.id:
            found.append(replica)

    return found