from flask import jsonify
from flask.views import View

from pycs.database.Database import Database


class ListProjects(View):
    """
    get a list of all available projects
    """
    # pylint: disable=arguments-differ
    methods = ['GET']

    def __init__(self, db: Database):
        # pylint: disable=invalid-name
        self.db = db

    def dispatch_request(self):
        projects = list(self.db.projects())
        return jsonify(projects)
