def revoke_api_key():
    """Form submission handler for revoking API keys."""
    build = g.build
    form = forms.RevokeApiKeyForm()
    if form.validate_on_submit():
        api_key = models.ApiKey.query.get(form.id.data)
        if api_key.build_id != build.id:
            logging.debug('User does not have access to API key=%r',
                          api_key.id)
            abort(403)

        api_key.active = False
        save_admin_log(build, revoked_api_key=True, message=api_key.id)

        db.session.add(api_key)
        db.session.commit()

        ops = operations.ApiKeyOps(api_key.id, api_key.secret)
        ops.evict()

    return redirect(url_for('manage_api_keys', build_id=build.id))
Form submission handler for revoking API keys.