Exemple #1
0
import six

import connexion
import swagger_server.controllers.ErrorApiResponse as ErrorApiResponse
import swagger_server.controllers.team_controller_impl as impl
from swagger_server import auth, util
from swagger_server.models.api_response import ApiResponse  # noqa: E501
from swagger_server.models.team import Team  # noqa: E501

AUTH_ERRORS = {
    auth.TokenStatus.EXPIRED: lambda role: ErrorApiResponse.TokenExpiredError(type='team'),
    auth.TokenStatus.INVALID: lambda role: ErrorApiResponse.TokenInvalidError(type='team'),
    auth.TokenStatus.NO_ROLE_GRANTED: lambda role: ErrorApiResponse.NoRoleGrantedError(role=role, type='team'),
    auth.TokenStatus.ROLE_GRANTED: None
}


def add_team(body):  # noqa: E501
    """Add a new team to the system. Role write:teams must be granted

     # noqa: E501

    :param body: Team object that needs to be added to the system
    :type body: dict | bytes

    :rtype: Team
    """
    role = auth.WRITE_TEAMS
    hasRole = auth.has_role(connexion.request.headers, role)
    if hasRole == auth.TokenStatus.ROLE_GRANTED:
        return impl.add_team(body)
import six

import connexion
import swagger_server.controllers.ErrorApiResponse as ErrorApiResponse
import swagger_server.controllers.leave_days_controller_impl as impl
from swagger_server import auth, util
from swagger_server.models.api_response import ApiResponse  # noqa: E501
from swagger_server.models.api_response_conflict import \
    ApiResponseConflict  # noqa: E501
from swagger_server.models.leave_days import LeaveDays  # noqa: E501

AUTH_ERRORS = {
    auth.TokenStatus.EXPIRED:
    lambda role: ErrorApiResponse.TokenExpiredError(type='leave days'),
    auth.TokenStatus.INVALID:
    lambda role: ErrorApiResponse.TokenInvalidError(type='leave days'),
    auth.TokenStatus.NO_ROLE_GRANTED:
    lambda role: ErrorApiResponse.NoRoleGrantedError(role=role,
                                                     type='leave days'),
    auth.TokenStatus.ROLE_GRANTED:
    None
}


def add_leave_days(body):  # noqa: E501
    """Add a employee LeaveDays to the system. Role write:leave_days must be granted

     # noqa: E501

    :param body: LeaveDays object that needs to be added to the system
    :type body: dict | bytes
Exemple #3
0
import six

import connexion
import swagger_server.controllers.ErrorApiResponse as ErrorApiResponse
import swagger_server.controllers.total_days_controller_impl as impl
from swagger_server import auth, util
from swagger_server.models.api_response import ApiResponse  # noqa: E501
from swagger_server.models.total_days import TotalDays  # noqa: E501

AUTH_ERRORS = {
    auth.TokenStatus.EXPIRED:
    lambda role: ErrorApiResponse.TokenExpiredError(type='total days'),
    auth.TokenStatus.INVALID:
    lambda role: ErrorApiResponse.TokenInvalidError(type='total days'),
    auth.TokenStatus.NO_ROLE_GRANTED:
    lambda role: ErrorApiResponse.NoRoleGrantedError(role=role,
                                                     type='total days'),
    auth.TokenStatus.ROLE_GRANTED:
    None
}


def add_total_days(body):  # noqa: E501
    """Add a employee total days to the system. Role write:total_days must be granted

     # noqa: E501

    :param body: TotalDays object that needs to be added to the system
    :type body: dict | bytes

    :rtype: TotalDays
Exemple #4
0
import six

import connexion
import swagger_server.controllers.employee_controller_impl as impl
import swagger_server.controllers.ErrorApiResponse as ErrorApiResponse
from swagger_server import auth, util
from swagger_server.models.api_response import ApiResponse  # noqa: E501
from swagger_server.models.employee import Employee  # noqa: E501

AUTH_ERRORS = {
    auth.TokenStatus.EXPIRED:
    lambda role: ErrorApiResponse.TokenExpiredError(type='employee'),
    auth.TokenStatus.INVALID:
    lambda role: ErrorApiResponse.TokenInvalidError(type='employee'),
    auth.TokenStatus.NO_ROLE_GRANTED:
    lambda role: ErrorApiResponse.NoRoleGrantedError(role=role,
                                                     type='employee'),
    auth.TokenStatus.ROLE_GRANTED:
    None
}


def add_employee(body):  # noqa: E501
    """Add a new employee to the system. Role write:employees must be granted

     # noqa: E501

    :param body: Employee object that needs to be added to the system
    :type body: dict | bytes

    :rtype: Employee
Exemple #5
0
import connexion
import six

from swagger_server.models.user import User  # noqa: E501
from swagger_server import util, auth
import swagger_server.controllers.ErrorApiResponse as ErrorApiResponse
import swagger_server.controllers.user_controller_impl as impl

AUTH_ERRORS = {
    auth.TokenStatus.EXPIRED:
    lambda role: ErrorApiResponse.TokenExpiredError(),
    auth.TokenStatus.INVALID:
    lambda role: ErrorApiResponse.TokenInvalidError(),
    auth.TokenStatus.NO_ROLE_GRANTED:
    lambda role: ErrorApiResponse.NoRoleGrantedError(role),
    auth.TokenStatus.ROLE_GRANTED:
    None
}


def authenticate_user(username, password):  # noqa: E501
    """Generates token for an user

     # noqa: E501

    :param username: The user name for login
    :type username: str
    :param password: The password for login in clear text
    :type password: str

    :rtype: str