from flask import g from auth.auth_view import RegisteredAuthorizedView from projects.services.projects_service import ProjectsService from projects.schemas import project_list_query_params, project_list_response_schema from flask_apispec import marshal_with, doc, use_kwargs @doc(tags=["Project"]) class ProjectListView(RegisteredAuthorizedView): """Endpoint for getting list of projects and creating new projects.""" service = ProjectsService() @doc(description='Retrieve projects list available for user') @use_kwargs(project_list_query_params, location='query') @marshal_with(project_list_response_schema, code=200, description='Projects list') @marshal_with(schema=None, code=403, description='Forbidden because of permissions.') @marshal_with(schema=None, code=401, description='User is not authenticated.') def get(self, params): """Retrieve projects list. Returns: HTTP 200: JSON with project list. Raises: HTTP 401: If user is not authenticated. """ return self.service.get_project_list(g.user_id, params)