def run_barman_config_switch(api: "PgBackupApi", args: Namespace) -> int:
    """Run a remote ``barman config-switch`` through the ``pg-backup-api``.

    :param api: a :class:`PgBackupApi` instance to handle communication with
        the API.
    :param args: arguments received from the command-line of
        ``patroni_barman config-switch`` command.

    :returns: the return code to be used when exiting the ``patroni_barman``
        application. Refer to :class:`ExitCode`.
    """
    if _should_skip_switch(args):
        logging.info("Config switch operation was skipped (role=%s, "
                     "switch_when=%s).", args.role, args.switch_when)
        return ExitCode.CONFIG_SWITCH_SKIPPED

    if not bool(args.barman_model) ^ bool(args.reset):
        logging.error("One, and only one among 'barman_model' ('%s') and "
                      "'reset' ('%s') should be given", args.barman_model, args.reset)
        return ExitCode.INVALID_ARGS

    return _switch_config(api, args.barman_server, args.barman_model, args.reset)
Run a remote ``barman config-switch`` through the ``pg-backup-api``.

    :param api: a :class:`PgBackupApi` instance to handle communication with
        the API.
    :param args: arguments received from the command-line of
        ``patroni_barman config-switch`` command.

    :returns: the return code to be used when exiting the ``patroni_barman``
        application. Refer to :class:`ExitCode`.
    
patroni/scripts/barman/config_switch.py