def request_run():
    """Requests a new run for a release candidate."""
    build = g.build
    current_release, current_run = _get_or_create_run(build)

    current_url = request.form.get('url', type=str)
    config_data = request.form.get('config', default='{}', type=str)
    utils.jsonify_assert(current_url, 'url to capture required')
    utils.jsonify_assert(config_data, 'config document required')

    config_artifact = _enqueue_capture(
        build, current_release, current_run, current_url, config_data)

    ref_url = request.form.get('ref_url', type=str)
    ref_config_data = request.form.get('ref_config', type=str)
    utils.jsonify_assert(
        bool(ref_url) == bool(ref_config_data),
        'ref_url and ref_config must both be specified or not specified')

    if ref_url and ref_config_data:
        ref_config_artifact = _enqueue_capture(
            build, current_release, current_run, ref_url, ref_config_data,
            baseline=True)
    else:
        _, last_good_run = _find_last_good_run(build)
        if last_good_run:
            current_run.ref_url = last_good_run.url
            current_run.ref_image = last_good_run.image
            current_run.ref_log = last_good_run.log
            current_run.ref_config = last_good_run.config

    db.session.add(current_run)
    db.session.commit()

    signals.run_updated_via_api.send(
        app, build=build, release=current_release, run=current_run)

    return flask.jsonify(
        success=True,
        build_id=build.id,
        release_name=current_release.name,
        release_number=current_release.number,
        run_name=current_run.name,
        url=current_run.url,
        config=current_run.config,
        ref_url=current_run.ref_url,
        ref_config=current_run.ref_config)
Requests a new run for a release candidate.