Set up a state id pause, this instructs a running state to pause at a given
    state id. This needs to pass in the jid of the running state and can
    optionally pass in a duration in seconds. If a state_id is not passed then
    the jid referenced will be paused at the beginning of the next state run.

    The given state id is the id got a given state execution, so given a state
    that looks like this:

    .. code-block:: yaml

        vim:
          pkg.installed: []

    The state_id to pass to `pause` is `vim`

    CLI Examples:

    .. code-block:: bash

        salt '*' state.pause 20171130110407769519
        salt '*' state.pause 20171130110407769519 vim
        salt '*' state.pause 20171130110407769519 vim 20

def pause(jid, state_id=None, duration=None):
    '''
    Set up a state id pause, this instructs a running state to pause at a given
    state id. This needs to pass in the jid of the running state and can
    optionally pass in a duration in seconds. If a state_id is not passed then
    the jid referenced will be paused at the beginning of the next state run.

    The given state id is the id got a given state execution, so given a state
    that looks like this:

    .. code-block:: yaml

        vim:
          pkg.installed: []

    The state_id to pass to `pause` is `vim`

    CLI Examples:

    .. code-block:: bash

        salt '*' state.pause 20171130110407769519
        salt '*' state.pause 20171130110407769519 vim
        salt '*' state.pause 20171130110407769519 vim 20
    '''
    jid = six.text_type(jid)
    if state_id is None:
        state_id = '__all__'
    data, pause_path = _get_pause(jid, state_id)
    if duration:
        data[state_id]['duration'] = int(duration)
    with salt.utils.files.fopen(pause_path, 'wb') as fp_:
        fp_.write(salt.utils.msgpack.dumps(data))