def delete_team(teamId): # noqa: E501 """Deletes an team. Role write:teams must be granteds # noqa: E501 :param teamId: Team id to delete :type teamId: int :rtype: ApiResponse """ role = auth.WRITE_TEAMS hasRole = auth.has_role(connexion.request.headers, role) if hasRole == auth.TokenStatus.ROLE_GRANTED: return impl.delete_team(teamId) return AUTH_ERRORS[hasRole](role), hasRole.http_status
def delete_leave_days(id): # noqa: E501 """Deletes a LeaveDays. Role write:leave_days must be granteds # noqa: E501 :param id: LeaveDays id to delete :type id: int :rtype: ApiResponse """ role = auth.WRITE_LEAVE_DAYS hasRole = auth.has_role(connexion.request.headers, role) if hasRole == auth.TokenStatus.ROLE_GRANTED: return impl.delete_leave_days(id) return AUTH_ERRORS[hasRole](role), hasRole.http_status
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) return AUTH_ERRORS[hasRole](role), hasRole.http_status
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 """ role = auth.WRITE_EMPLOYEES hasRole = auth.has_role(connexion.request.headers, role) if hasRole == auth.TokenStatus.ROLE_GRANTED: return impl.add_employee(body) return AUTH_ERRORS[hasRole](role), hasRole.http_status
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 :rtype: LeaveDays """ role = auth.WRITE_LEAVE_DAYS hasRole = auth.has_role(connexion.request.headers, role) if hasRole == auth.TokenStatus.ROLE_GRANTED: return impl.add_leave_days(body) return AUTH_ERRORS[hasRole](role), hasRole.http_status
def delete_employee(employeeId): # noqa: E501 """Deletes an employee. Role write:employees must be granteds # noqa: E501 :param employeeId: Employee id to delete :type employeeId: int :rtype: ApiResponse """ role = auth.WRITE_EMPLOYEES hasRole = auth.has_role(connexion.request.headers, role) if hasRole == auth.TokenStatus.ROLE_GRANTED: return impl.delete_employee(employeeId) return AUTH_ERRORS[hasRole](role), hasRole.http_status
def get_user_by_id(id): # noqa: E501 """Gets user by id. Role read:users role must be granted # noqa: E501 :param id: The id of user that needs to be fetched :type id: int :rtype: UserSafe """ role = auth.READ_USERS hasRole = auth.has_role(connexion.request.headers, role) if hasRole == auth.TokenStatus.ROLE_GRANTED: return impl.get_user_by_id(id) return AUTH_ERRORS[hasRole](role), hasRole.http_status
def delete_user(id): # noqa: E501 """Delete user This can only be done with write:users role. # noqa: E501 :param id: The id of user that needs to be deleted :type id: int :rtype: ApiResponse """ role = auth.WRITE_USERS hasRole = auth.has_role(connexion.request.headers, role) if hasRole == auth.TokenStatus.ROLE_GRANTED: return impl.delete_user(id) return AUTH_ERRORS[hasRole](role), hasRole.http_status
def create_user(body): # noqa: E501 """Create user Role write:users role must be granted # noqa: E501 :param body: Created user object :type body: dict | bytes :rtype: UserSafe """ role = auth.WRITE_USERS hasRole = auth.has_role(connexion.request.headers, role) if hasRole == auth.TokenStatus.ROLE_GRANTED: return impl.create_user(body) return AUTH_ERRORS[hasRole](role), hasRole.http_status
def get_user_by_name(username): # noqa: E501 """Gets user by user name. Role read:users role must be granted # noqa: E501 :param username: The name of user that needs to be fetched. :type username: str :rtype: UserSafe """ role = auth.READ_USERS hasRole = auth.has_role(connexion.request.headers, role) if hasRole == auth.TokenStatus.ROLE_GRANTED: return impl.get_user_by_name(username) return AUTH_ERRORS[hasRole](role), hasRole.http_status
def update_team_by_id(teamId, body): # noqa: E501 """Updates a team in the system with form data. Role write:teams must be granted # noqa: E501 :param teamId: ID of team to return :type teamId: int :param body: Team object that needs to be updated in 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.update_team_by_id(teamId, body) return AUTH_ERRORS[hasRole](role), hasRole.http_status
def update_leave_days_by_id(id, body): # noqa: E501 """Updates a LeaveDays in the system with form data. Role write:leave_days must be granted # noqa: E501 :param id: ID of LeaveDays to return :type id: int :param body: LeaveDays object that needs to be updated in the system :type body: dict | bytes :rtype: LeaveDays """ role = auth.WRITE_LEAVE_DAYS hasRole = auth.has_role(connexion.request.headers, role) if hasRole == auth.TokenStatus.ROLE_GRANTED: return impl.update_leave_days_by_id(id, body) return AUTH_ERRORS[hasRole](role), hasRole.http_status
def update_user(id, body): # noqa: E501 """Updated user This can only be done by with write:users role. # noqa: E501 :param id: The id of user that needs to be updated :type id: int :param body: Updated user object :type body: dict | bytes :rtype: UserSafe """ role = auth.WRITE_USERS hasRole = auth.has_role(connexion.request.headers, role) if hasRole == auth.TokenStatus.ROLE_GRANTED: return impl.update_user(id, body) return AUTH_ERRORS[hasRole](role), hasRole.http_status
def update_employee_by_id(employeeId, body): # noqa: E501 """Updates an employee in the system with form data. Role write:employees must be granted # noqa: E501 :param employeeId: ID of empoyee to return :type employeeId: int :param body: Employee object that needs to be updated in the system :type body: dict | bytes :rtype: Employee """ role = auth.WRITE_EMPLOYEES hasRole = auth.has_role(connexion.request.headers, role) if hasRole == auth.TokenStatus.ROLE_GRANTED: return impl.update_employee_by_id(employeeId, body) return AUTH_ERRORS[hasRole](role), hasRole.http_status
def find_by(username=None, email=None, roles=None): # noqa: E501 """Finds users by given parameters. Role read:users role must be granted # noqa: E501 :param username: The username to filter by. :type username: str :param email: The email to filter by. :type email: str :param roles: Roles to filter by. :type roles: str :rtype: List[UserSafe] """ role = auth.READ_USERS hasRole = auth.has_role(connexion.request.headers, role) if hasRole == auth.TokenStatus.ROLE_GRANTED: return impl.find_by(username, email, roles) return AUTH_ERRORS[hasRole](role), hasRole.http_status