def update_ld_api(project: str, environment: str, feature: str, state: str):
    """
    Execute command against the LaunchDarkly API.

    This command is generally not used directly, instead it is called as a
    part of running the ``playback()`` function.

    :param project: LaunchDarkly project key.
    :param environment: LaunchDarkly environment key.
    :param feature: LaunchDarkly feature key.
    :param state: State for a feature flag.
    """
    ld_api = LaunchDarklyApi(
        os.environ.get('LD_API_KEY'),
        project,
        environment
    )

    if valid_state(state):
        if state.lower() == 'off':
            new_state = False
        else:
            new_state = True
        ld_api.update_flag(new_state, feature)
    else:
        raise ValueError('Invalid state: {0}, -s needs to be either \
            on or off.'.format(state))
Execute command against the LaunchDarkly API.

    This command is generally not used directly, instead it is called as a
    part of running the ``playback()`` function.

    :param project: LaunchDarkly project key.
    :param environment: LaunchDarkly environment key.
    :param feature: LaunchDarkly feature key.
    :param state: State for a feature flag.