{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "https://apidocs.iqrf.org/openapi/iqrf-gateway-webapp/v2.7.0-rc3/schemas/definitions/wireGuard.json",
    "definitions": {
        "ipv4": {
            "type": "object",
            "title": "WireGuard IPv4 configuration",
            "examples": [
                {
                    "address": "10.0.0.0",
                    "prefix": 24
                }
            ],
            "required": [
                "address",
                "prefix"
            ],
            "additionalProperties": false,
            "properties": {
                "address": {
                    "title": "WireGuard IPv4 address",
                    "type": "string",
                    "format": "ipv4",
                    "example": "10.0.0.35"
                },
                "prefix": {
                    "title": "WireGuard IPv4 address prefix",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 32,
                    "example": 24
                }
            }
        },
        "ipv6": {
            "type": "object",
            "title": "WireGuard IPv6 configuration",
            "examples": [
                {
                    "address": "fd86:ea04:1115::35",
                    "prefix": 64
                }
            ],
            "required": [
                "address",
                "prefix"
            ],
            "additionalProperties": false,
            "properties": {
                "address": {
                    "title": "WireGuard IPv6 address",
                    "type": "string",
                    "format": "ipv6",
                    "example": "fd86:ea04:1115::35"
                },
                "prefix": {
                    "title": "WireGuard IPv6 address prefix",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 128,
                    "example": 64
                }
            }
        },
        "privateKey": {
            "type": "string",
            "pattern": "^[A-Za-z0-9+/]{42}[AEIMQUYcgkosw480]=$",
            "title": "WireGuard private key",
            "example": "+DsMmGWks1DawE1yc4UlOI6pbH3XVxdVArj9lLOyD18="
        },
        "publicKey": {
            "type": "string",
            "title": "WireGuard public key",
            "pattern": "^[A-Za-z0-9+/]{42}[AEIMQUYcgkosw480]=$",
            "example": "2OGuuIWQLKvtVYGntdHSoRb8MtDyKq6wxKd9vQphzDQ="
        },
        "psk": {
            "title": "WireGuard pre-shared key",
            "example": "Tkyhh13wpqw/ffriFSQtR8TNdxyT9s2MPhqLlT5Z2SA=",
            "type": [
                "string",
                "null"
            ],
            "pattern": "^[A-Za-z0-9+/]{42}[AEIMQUYcgkosw480]=$"
        },
        "name": {
            "title": "WireGuard tunnel name",
            "type": "string",
            "description": "WireGuard interface name",
            "example": "wg0"
        },
        "peers": {
            "title": "WireGuard tunnel peers",
            "type": "array",
            "uniqueItems": true,
            "items": {
                "title": "WireGuard tunnel peer object",
                "type": "object",
                "required": [
                    "publicKey",
                    "persistentKeepalive",
                    "endpoint",
                    "port",
                    "allowedIps"
                ],
                "additionalProperties": false,
                "properties": {
                    "publicKey": {
                        "$ref": "https://apidocs.iqrf.org/openapi/iqrf-gateway-webapp/v2.7.0-rc3/schemas/definitions/wireGuard.json#/definitions/publicKey"
                    },
                    "psk": {
                        "$ref": "https://apidocs.iqrf.org/openapi/iqrf-gateway-webapp/v2.7.0-rc3/schemas/definitions/wireGuard.json#/definitions/psk"
                    },
                    "persistentKeepalive": {
                        "title": "WireGuard tunnel peer keepalive interval",
                        "type": "integer",
                        "minimum": 0,
                        "example": 25
                    },
                    "endpoint": {
                        "title": "WireGuard tunnel peer endpoint",
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                            "address",
                            "port"
                        ],
                        "properties": {
                            "address": {
                                "title": "WireGuard tunnel peer endpoint address",
                                "type": "string",
                                "format": "hostname"
                            },
                            "port": {
                                "title": "WireGuard tunnel peer endpoint port",
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 65535
                            }
                        },
                        "example": {
                            "address": "vpn.example.org",
                            "port": 51820
                        }
                    },
                    "port": {
                        "$ref": "https://apidocs.iqrf.org/openapi/iqrf-gateway-webapp/v2.7.0-rc3/schemas/definitions/wireGuard.json#/definitions/port"
                    },
                    "allowedIps": {
                        "title": "WireGuard tunnel peer allowed IP addresses",
                        "type": "array",
                        "uniqueItems": true,
                        "items": {
                            "oneOf": [
                                {
                                    "$ref": "https://apidocs.iqrf.org/openapi/iqrf-gateway-webapp/v2.7.0-rc3/schemas/definitions/wireGuard.json#/definitions/ipv4"
                                },
                                {
                                    "$ref": "https://apidocs.iqrf.org/openapi/iqrf-gateway-webapp/v2.7.0-rc3/schemas/definitions/wireGuard.json#/definitions/ipv6"
                                }
                            ]
                        }
                    }
                }
            }
        },
        "port": {
            "title": "WireGuard tunnel listen port",
            "type": "integer",
            "minimum": 0,
            "maximum": 65535,
            "example": 58775
        },
        "mtu": {
            "title": "WireGuard interface MTU",
            "type": "integer",
            "minimum": 1,
            "maximum": 65535,
            "default": 1420,
            "example": 1420
        }
    }
}
