---
proxies:
  description: Proxy configuration
  _type: leadership

  title:
    description: Title or Description
    multi: true
    mandatory: false

  type:
    description: Proxy Type
    type: choice
    choices:
      - HTTP
      - HTTPS/SSL
      - SOCKS4
      - SOCKS5
      - PAC URL
      - WPAD
      - System (use system settings)
      - Direct (no proxy)
    default: Direct (no proxy)

  color:
    description: Color
#    validators:
#      - type: jinja
#        jinja: |
#          {% if _.color | regex_search('/^#([A-F0-9]{3}|[A-F0-9]{6})$/i') %}
#          not a valid color, should be somethink like #000000
#          {% endif %}

  address:
    description: IP address, DNS name, server name
    disabled: &needs_address
      type: jinja
      jinja: |
        {% if _.type not in ['HTTP', 'HTTPS/SSL', 'SOCKS4', 'SOCKS5'] %}
        disabled
        {% endif %}
      description: |
        if type not in:
        - HTTP
        - HTTPS/SSL
        - SOCKS4
        - SOCKS5
    default:
      type: jinja
      jinja: |
        {% if firefox_address is not undefined %}
        {{ firefox_address }}
        {% endif %}
      params:
        firefox_address:
          type: variable
          variable: firefox.manual.http_proxy.address
          propertyerror: false
      description: copy HTTP address if proxy is not "Manual"

  port:
    description: Port
    type: port
    default:
      type: jinja
      jinja: |
        {% if firefox_port is not undefined %}
        {{ firefox_port }}
        {% endif %}
      params:
        firefox_port:
          type: variable
          variable: firefox.manual.http_proxy.port
          propertyerror: false
      description: copy HTTP port if proxy is not "Manual"
    disabled: *needs_address

  username:
    description: Username
    type: unix_user
    mandatory:
      type: jinja
      jinja: |
        {% if password is not undefined and password %}
        username is mandatory
        {% endif %}
      params:
        password:
          type: variable
          variable: _.password
          propertyerror: false
      description: if a password is set
    disabled: *needs_address

  password:
    description: Password
    type: secret
    mandatory: false
    disabled: *needs_address

  url:
    description: URL
    type: web_address
    disabled:
      type: jinja
      jinja: |
        {% if _.type not in ['PAC URL', 'WPAD'] %}
        proxy does not need url
        {% endif %}
      description: |
        if type is not in:
        - PAC URL
        - WPAD
    default:
      type: jinja
      jinja: |
        {% if firefox_url is not undefined %}
        {{ firefox_url }}
        {% endif %}
      params:
        firefox_url:
          type: variable
          variable: firefox.auto
          propertyerror: false
      description: copy HTTP address if proxy is "Auto"
