def all(): if not flask.g.am_admin: flask.abort(http.client.FORBIDDEN) users = [get_user_basic(u) for u in webapp.user.get_users()] return utils.jsonify(utils.get_json(users=users), schema_url=flask.url_for("api_schema.users", _external=True))
def software(): result = [{ "name": s[0], "version": s[1], "href": s[2] } for s in webapp.about.get_software()] return utils.jsonify(utils.get_json(software=result), schema_url=utils.url_for("api_schema.about_software"))
def logs(username): user = webapp.user.get_user(username=username) if not user: flask.abort(http.client.NOT_FOUND) if not webapp.user.am_admin_or_self(user): flask.abort(http.client.FORBIDDEN) return utils.jsonify(utils.get_json(user=get_user_basic(user), logs=utils.get_logs(user["iuid"])), schema_url=utils.url_for("api_schema.logs"))
def display(username): user = webapp.user.get_user(username=username) if not user: flask.abort(http.client.NOT_FOUND) if not webapp.user.am_admin_or_self(user): flask.abort(http.client.FORBIDDEN) user.pop("password", None) user.pop("apikey", None) user["logs"] = {"href": utils.url_for(".logs", username=user["username"])} return utils.jsonify(utils.get_json(**user), schema_url=utils.url_for("api_schema.user"))
def root(): "API root." items = { "schema": { "root": { "href": flask.url_for("api_schema.root", _external=True) }, "logs": { "href": flask.url_for("api_schema.logs", _external=True) }, "user": { "href": flask.url_for("api_schema.user", _external=True) }, "users": { "href": flask.url_for("api_schema.users", _external=True) }, "about/software": { "href": flask.url_for("api_schema.about_software", _external=True) } }, "about": { "software": { "href": flask.url_for("api_about.software", _external=True) } } } if flask.g.current_user: items["user"] = { "username": flask.g.current_user["username"], "href": flask.url_for("api_user.display", username=flask.g.current_user["username"], _external=True) } if flask.g.am_admin: items["users"] = { "href": flask.url_for("api_user.all", _external=True) } return utils.jsonify(utils.get_json(**items), schema_url=flask.url_for("api_schema.root", _external=True))