def METHOD_NAME(self, role_ids):
    missing_ids = []
    roles_new = []
    for role_id in role_ids:
        role = Role.query.get(int(role_id))
        if role is None:
            missing_ids.append(role_id)
        else:
            roles_new.append(role)
    if len(missing_ids) > 0:
        error = ApiError.RESOURCE_INVALID.copy()
        error.update(
            {'message': f'Roles with ids: {missing_ids} do not exist'})
        raise ApiError(error)
    return roles_new