from flask_restplus import Resource
import sqlalchemy

from app.extensions import db
from app.extensions.api import api_v1, abort, http_exceptions
from app.extensions.api.parameters import PaginationParameters
from app.modules.users import permissions
from app.modules.users.models import User

from . import parameters, schemas
from .models import Team, TeamMember


log = logging.getLogger(__name__) # pylint: disable=invalid-name
namespace = api_v1.namespace('teams', description="Teams") # pylint: disable=invalid-name


@namespace.route('/')
class Teams(Resource):
    """
    Manipulations with teams.
    """

    @api_v1.login_required(scopes=['teams:read'])
    @api_v1.parameters(PaginationParameters())
    @api_v1.response(schemas.BaseTeamSchema(many=True))
    def get(self, args):
        """
        List of teams.
import logging

from flask_login import current_user
from flask_restplus import Resource
import sqlalchemy

from app.extensions.api import api_v1, abort, http_exceptions
from app.extensions.api.parameters import PaginationParameters

from . import permissions, schemas, parameters
from .models import db, User


log = logging.getLogger(__name__)
namespace = api_v1.namespace('users', description="Users")


@namespace.route('/')
class Users(Resource):
    """
    Manipulations with users.
    """

    @api_v1.login_required(scopes=['users:read'])
    @api_v1.permission_required(permissions.AdminRolePermission())
    @api_v1.parameters(PaginationParameters())
    @api_v1.response(schemas.BaseUserSchema(many=True))
    def get(self, args):
        """
        List of users.
import logging

from flask_restplus import Resource
import sqlalchemy

from app.extensions import db
from app.extensions.api import api_v1, abort, http_exceptions
from app.extensions.api.parameters import PaginationParameters
from app.modules.users import permissions
from app.modules.users.models import User

from . import parameters, schemas
from .models import Team, TeamMember

log = logging.getLogger(__name__)  # pylint: disable=invalid-name
namespace = api_v1.namespace('teams', description="Teams")  # pylint: disable=invalid-name


@namespace.route('/')
class Teams(Resource):
    """
    Manipulations with teams.
    """
    @api_v1.login_required(scopes=['teams:read'])
    @api_v1.parameters(PaginationParameters())
    @api_v1.response(schemas.BaseTeamSchema(many=True))
    def get(self, args):
        """
        List of teams.

        Returns a list of teams starting from ``offset`` limited by ``limit``