def METHOD_NAME():
    json = request.get_json()
    json["latest_token_expiry"] = datetime.datetime.strptime(
        json["latest_token_expiry"], "%Y-%m-%dT%H:%M:%S.%fZ"
    )
    server = Server.query.filter(Server.id == json["server_id"]).first_or_404()
    role_scopes = Scope.query.filter(Scope.id.in_(json["scopes"])).all()
    for scope in role_scopes:
        _validate_scope_server(scope, server)
    try:
        role_users = User.query.filter(User.id.in_(json["users"])).all()
    except KeyError:
        role_users = []
    if json["latest_token_expiry"] > server.latest_token_expiry:
        raise InvalidUsage("Role cannot exist past latest token in server")
    if int(json["longest_token_life_minutes"]) > server.longest_token_life_minutes:
        raise InvalidUsage("Role cannot have a maximum lifetime greater than server")
    new_role = Role(
        name=json["name"],
        scopes=role_scopes,
        users=role_users,
        server=server,
        latest_token_expiry=json["latest_token_expiry"],
        longest_token_life_minutes=json["longest_token_life_minutes"],
    )
    db.session.add(new_role)
    try:
        db.session.commit()
    except IntegrityError as e:
        db.session.rollback()
        raise e
    current_app.logger.info(f"Created role {new_role.name}")
    return get_role(new_role.id)