def _set(self, opts):
    cmd = 'create'
    if opts.edit:
        cmd = 'edit'
    if (opts.name is None):
        _exit_if_errors([f'--xdcr-cluster-name is required to {cmd} a cluster connection'])
    if (opts.hostname is None):
        _exit_if_errors([f'--xdcr-hostname is required to {cmd} a cluster connections'])
    if (opts.username is None):
        _exit_if_errors([f'--xdcr-username is required to {cmd} a cluster connections'])
    if (opts.password is None):
        _exit_if_errors([f'--xdcr-password is required to {cmd} a cluster connections'])
    if (((opts.encrypt is not None) or (opts.encryption_type is not None)) and (opts.secure_connection is not None)):
        _exit_if_errors(['Cannot use deprecated flags --xdcr-demand-encryption or --xdcr-encryption-type with --xdcr-secure-connection'])
    if (opts.secure_connection == 'none'):
        opts.encrypt = '0'
        opts.encryption_type = None
    elif (opts.secure_connection == 'half'):
        opts.encrypt = '1'
        opts.encryption_type = 'half'
    elif (opts.secure_connection == 'full'):
        opts.encrypt = '1'
        opts.encryption_type = 'full'
    elif ((opts.encrypt is None) and (opts.encryption_type is None)):
        opts.encrypt = '0'
        opts.encryption_type = None
    raw_cert = None
    if (opts.encrypt == '1'):
        if (opts.encryption_type is None):
            opts.encryption_type = 'full'
        if (opts.encryption_type == 'full'):
            if (opts.certificate is None):
                _exit_if_errors(['certificate required if encryption is demanded'])
            raw_cert = _exit_on_file_read_failure(opts.certificate)
    raw_user_key = None
    if opts.r_key:
        raw_user_key = _exit_on_file_read_failure(opts.r_key)
    raw_user_cert = None
    if opts.r_certificate:
        raw_user_cert = _exit_on_file_read_failure(opts.r_certificate)
    if opts.create:
        (_, errors) = self.rest.create_xdcr_reference(opts.name, opts.hostname, opts.r_username, opts.r_password, opts.encrypt, opts.encryption_type, raw_cert, raw_user_cert, raw_user_key)
        _exit_if_errors(errors)
        _success('Cluster reference created')
    else:
        (_, errors) = self.rest.edit_xdcr_reference(opts.name, opts.hostname, opts.r_username, opts.r_password, opts.encrypt, opts.encryption_type, raw_cert, raw_user_cert, raw_user_key)
        _exit_if_errors(errors)
        _success('Cluster reference edited')
def _set(self, opts):
    cmd = 'create'
    if opts.edit:
        cmd = 'edit'
    if (opts.name is None):
        _exit_if_errors([f'--xdcr-cluster-name is required to {cmd} a cluster connection'])
    if (opts.hostname is None):
        _exit_if_errors([f'--xdcr-hostname is required to {cmd} a cluster connections'])
    if (opts.username is None):
        _exit_if_errors([f'--xdcr-username is required to {cmd} a cluster connections'])
    if (opts.password is None):
        _exit_if_errors([f'--xdcr-password is required to {cmd} a cluster connections'])
    if (((opts.encrypt is not None) or (opts.encryption_type is not None)) and (opts.secure_connection is not None)):
        _exit_if_errors(['Cannot use deprecated flags --xdcr-demand-encryption or --xdcr-encryption-type with --xdcr-secure-connection'])
    if (opts.secure_connection == 'none'):
        opts.encrypt = '0'
        opts.encryption_type = None
    elif (opts.secure_connection == 'half'):
        opts.encrypt = '1'
        opts.encryption_type = 'half'
    elif (opts.secure_connection == 'full'):
        opts.encrypt = '1'
        opts.encryption_type = 'full'
    elif ((opts.encrypt is None) and (opts.encryption_type is None)):
        opts.encrypt = '0'
        opts.encryption_type = None
    raw_cert = None
    if (opts.encrypt == '1'):
        if (opts.encryption_type is None):
            opts.encryption_type = 'full'
        if (opts.encryption_type == 'full'):
            if (opts.certificate is None):
                _exit_if_errors(['certificate required if encryption is demanded'])
            raw_cert = _exit_on_file_read_failure(opts.certificate)
    raw_user_key = None
    if opts.r_key:
        raw_user_key = _exit_on_file_read_failure(opts.r_key)
    raw_user_cert = None
    if opts.r_certificate:
        raw_user_cert = _exit_on_file_read_failure(opts.r_certificate)
    if opts.create:
        (_, errors) = self.rest.create_xdcr_reference(opts.name, opts.hostname, opts.r_username, opts.r_password, opts.encrypt, opts.encryption_type, raw_cert, raw_user_cert, raw_user_key)
        _exit_if_errors(errors)
        _success('Cluster reference created')
    else:
        (_, errors) = self.rest.edit_xdcr_reference(opts.name, opts.hostname, opts.r_username, opts.r_password, opts.encrypt, opts.encryption_type, raw_cert, raw_user_cert, raw_user_key)
        _exit_if_errors(errors)
        _success('Cluster reference edited')