async def configure(ssid: str,
                    securityType: SECURITY_TYPES,
                    psk: Optional[str] = None,
                    hidden: bool = False,
                    eapConfig: Optional[Dict[str, Any]] = None,
                    upRetries: int = 2) -> Tuple[bool, str]:
    """ Configure a connection but do not bring it up (though it is configured
    for autoconnect).

    Returns (success, message) where ``success`` is a ``bool`` and ``message``
    is a ``str``.

    Only anticipated failures are treated that way - for instance, an ssid
    that doesn't exist will get a False and a message; a system where nmcli
    is not found will raise a CalledProcessError.

    Input checks should be conducted before calling this function; any issues
    with arguments that make it to this function will probably surface
    themselves as TypeErrors and ValueErrors rather than anything more
    structured.

    The ssid and security_type arguments are mandatory; the others have
    different requirements depending on the security type.
    """
    already = await connection_exists(ssid)
    if already:
        # TODO(seth, 8/29/2018): We may need to do connection modifies
        # here for EAP configuration if e.g. we’re passing a keyfile in a
        # different http request
        _1, _2 = await _call(['connection', 'delete', already])

    configure_cmd = _build_con_add_cmd(
        ssid, securityType, psk, hidden, eapConfig)
    res, err = await _call(configure_cmd)

    # nmcli connection add returns a string that looks like
    # "Connection ’connection-name’ (connection-uuid) successfully added."
    # This unfortunately doesn’t respect the --terse flag, so we need to
    # regex out the name or the uuid to use later in connection up; the
    # uuid is slightly more regular, so that’s what we use.
    uuid_matches = re.search(  # noqa
        "Connection '(.*)'[\s]+\(([\w\d-]+)\) successfully", res)  # noqa
    if not uuid_matches:
        return False, err.split('\r')[-1]
    name = uuid_matches.group(1)
    uuid = uuid_matches.group(2)
    for _ in range(upRetries):
        res, err = await _call(['connection', 'up', 'uuid', uuid])
        if 'Connection successfully activated' in res:
            # If we successfully added the connection, remove other wifi
            # connections so they don’t accumulate over time

            _3, _4 = await _trim_old_connections(name,
                                                 CONNECTION_TYPES.WIRELESS)
            return True, res
    else:
        return False, err.split('\r')[-1]
Configure a connection but do not bring it up (though it is configured
    for autoconnect).

    Returns (success, message) where ``success`` is a ``bool`` and ``message``
    is a ``str``.

    Only anticipated failures are treated that way - for instance, an ssid
    that doesn't exist will get a False and a message; a system where nmcli
    is not found will raise a CalledProcessError.

    Input checks should be conducted before calling this function; any issues
    with arguments that make it to this function will probably surface
    themselves as TypeErrors and ValueErrors rather than anything more
    structured.

    The ssid and security_type arguments are mandatory; the others have
    different requirements depending on the security type.