{
    'connection':
        {
            'id': <'{{ name }}'>,
{% if interface.type != "vlan" %}
            'interface-name': <'{{ interface.name }}'>,
{% endif %}
            'type': <'{% if interface.type == "ethernet" %}802-3-ethernet{% elif interface.type == "wireless" %}802-11-wireless{% else %}{{ interface.type.value }}{% endif %}'>,
            'uuid': <'{{ uuid }}'>,
            'llmnr': <uint32 2>,
            'mdns': <uint32 2>
        }

{% if interface.ipv4 %}
    ,
    'ipv4':
        {
{% if interface.ipv4.method == "auto" %}
            'method': <'auto'>
{% elif interface.ipv4.method == "disabled" %}
            'method': <'disabled'>
{% else %}
            'method': <'manual'>,
            'dns': <[uint32 {{ interface.ipv4.nameservers | map("ipv4_to_int") | join(",") }}]>,
            'address-data': <[
            {% for address in interface.ipv4.address %}
                {
                    'address': <'{{ address.ip | string }}'>,
                    'prefix': <uint32 {{ address.with_prefixlen.partition("/") | last | int }}>
                }]>,
            {% endfor %}
            'gateway': <'{{ interface.ipv4.gateway | string }}'>
{% endif %}
        }
{% endif %}

{% if interface.ipv6 %}
    ,
    'ipv6':
        {
{% if interface.ipv6.method == "auto" %}
            'method': <'auto'>
{% elif interface.ipv6.method == "disabled" %}
            'method': <'disabled'>
{% else %}
            'method': <'manual'>,
            'dns': <[{{ interface.ipv6.nameservers | map("ipv6_to_byte") | join(",") }}]>,
            'address-data': <[
            {% for address in interface.ipv6.address if not address.with_prefixlen.startswith("fe80::") %}
                {
                    'address': <'{{ address.ip | string }}'>,
                    'prefix': <uint32 {{ address.with_prefixlen.partition("/") | last | int }}>
                }]>,
            {% endfor %}
            'gateway': <'{{ interface.ipv6.gateway | string }}'>
{% endif %}
        }
{% endif %}

{% if interface.type == "ethernet" %}
    ,
    '802-3-ethernet':
        {
            'assigned-mac-address': <'preserve'>
        }
{% endif %}

{% if interface.type == "vlan" %}
    ,
    'vlan':
        {
            'id': <uint32 {{ interface.vlan.id }}>,
            'parent': <'{{ interface.vlan.interface }}'>
        }
{% endif %}

{% if interface.type == "wireless" %}
    ,
    '802-11-wireless':
        {
            'assigned-mac-address': <'preserve'>,
            'ssid': <[byte {{ interface.wifi.ssid }}]>,
            'mode': <'{{ interface.wifi.mode.value }}'>,
            'powersave': <uint32 1>
{% if interface.wifi.auth != "open" %}
            ,
            'security': <'802-11-wireless-security'>
        },

    '802-11-wireless-security':
        {
        {% if interface.wifi.auth == "wep" %}
            'auth-alg': <'none'>,
            'key-mgmt': <'none'>
        {% elif interface.wifi.auth == "wpa-psk" %}
            'auth-alg': <'open'>,
            'key-mgmt': <'wpa-psk'>
        {% endif %}
        {% if interface.wifi.psk %}
            ,
            'psk': <'{{ interface.wifi.psk }}'>
        {% endif %}
{% endif %}
        }
{% endif %}
}