def add_project_user(project_id): user_id = parse_request_data(required=_SCHEMA.required)['id'] tenant = get_tenant(project_id) user = _get_user(user_id) set_audit_resource_id(user_id) try: tenant.add_user(user.id, member_role_id()) except osc_exc.NotFound: user = _get_user(user_id) # check that user still exists abort(404) # if user still exists, tenant was removed return make_json_response(link_for_user(user))
def get_project_user(project_id, user_id): for user in _project_users_list(project_id): if user.id == user_id: return make_json_response(link_for_user(user)) abort(404)
def list_project_users(project_id): parse_collection_request(_SCHEMA) result = [link_for_user(user) for user in _project_users_list(project_id)] parent_href = url_for('projects.get_project', project_id=project_id) return make_collection_response(u'users', result, parent_href=parent_href)