from flask import request, Response
from db.repository import Repository
from db.entities import ClusterSet

repo = Repository()

def get():
    return [c.to_serializable_dict() for c in repo.get_clustersets()]

def get_names():
    return repo.get_clusterset_names()

def get_by_name(layername):
    res = repo.get_clusterset(layername)
    if res is not None:
        return res.to_serializable_dict() 
    else:
        return Response(status=404)