def get(self, context, request_args, pagination_params): """Get all users. Requires project admin privileges.""" user_id = request_args["id"] user_name = request_args["name"] if user_id: user_obj = dbapi.users_get_by_id(context, user_id) user_obj.data = user_obj.variables users_obj = [user_obj] link_params = {} if user_name: users_obj, link_params = dbapi.users_get_by_name( context, user_name, request_args, pagination_params, ) else: users_obj, link_params = dbapi.users_get_all( context, request_args, pagination_params, ) links = base.links_from(link_params) response_body = {'users': users_obj, 'links': links} return jsonutils.to_primitive(response_body), 200, None
def get(self, id): """Get a user details by id. Requires project admin privileges.""" context = request.environ.get('context') try: user_obj = dbapi.users_get_by_id(context, id) except exceptions.AdminRequired: return self.error_response(401, 'This is admin only resource.') except exceptions.NotFound: return self.error_response(404, 'Not Found') except Exception as err: LOG.error("Error during User get by id: %s" % err) return self.error_response(500, 'Unknown Error') user = jsonutils.to_primitive(user_obj) return user, 200, None
def get(self): """Get all users. Requires project admin privileges.""" user_id = g.args["id"] user_name = g.args["name"] context = request.environ.get('context') if not user_id and not user_name: try: users_obj = dbapi.users_get_all(context) except exceptions.AdminRequired: return self.error_response(401, 'This is admin only resource.') if users_obj: result = jsonutils.to_primitive(users_obj) return result, 200, None else: return None, 404, None if user_name: try: users_obj = dbapi.users_get_by_name(context, user_name) except exceptions.AdminRequired: return self.error_response(401, 'This is admin only resource.') if users_obj: result = jsonutils.to_primitive(users_obj) return [result], 200, None else: return None, 404, None # User Ids are unique if user_id: try: user_obj = dbapi.users_get_by_id(context, user_id) except exceptions.AdminRequired: return self.error_response(401, 'This is admin only resource.') except exceptions.NotFound: return self.error_response(404, 'Not Found') if user_obj: user_obj.data = user_obj.variables result = jsonutils.to_primitive(user_obj) return [result], 200, None else: return None, 404, None
def get(self): """Get all users. Requires project admin privileges.""" user_id = g.args["id"] user_name = g.args["name"] context = request.environ.get('context') if user_name: user_obj = dbapi.users_get_by_name(context, user_name) user_obj.data = user_obj.variables return jsonutils.to_primitive([user_obj]), 200, None if user_id: user_obj = dbapi.users_get_by_id(context, user_id) user_obj.data = user_obj.variables return jsonutils.to_primitive([user_obj]), 200, None users_obj = dbapi.users_get_all(context) return jsonutils.to_primitive(users_obj), 200, None
def get(self, id): """Get a user details by id. Requires project admin privileges.""" context = request.environ.get('context') user_obj = dbapi.users_get_by_id(context, id) return jsonutils.to_primitive(user_obj), 200, None